0

I get error messages "Missing number, treated as zero" and unwanted spaces before the tcbox'es in math mode (text mode is fine). What am I doing incorrectly? My code is:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tcolorbox}
\renewcommand{\equiv}{\text{\tcbox{=}}}
\begin{document}
$w - 2\equiv v\equiv v$
\strut \newline
\strut \newline
\strut \newline
w - 2\equiv v\equiv v
\end{document}

In overleaf + pdfLaTeX, it yields the following (1st line is where the problem is, 2nd line as expected).

enter image description here

EDIT

I have reduced @Zarko's answer a bit to show what options were used to eliminate the problems:

\usepackage[most]{tcolorbox}
\tcbset{on line,
    left=-1pt,right=-1pt,top=1pt,bottom=0pt,
    highlight math style={enhanced}}
\renewcommand{\equiv}{\;\tcbhighmath{-->}\;}
Yulia V
  • 115
  • 4

1 Answers1

5

It is not entirely clear what you after. I guess that you actually looking for something like this:

enter image description here

Based on this answer your MWE can be rewritten as:

\documentclass{article}
\usepackage{amsmath}
\usepackage[most]{tcolorbox}

\tcbset{on line, % borrowed from https://tex.stackexchange.com/questions/568880/ boxsep=0pt, % left=1pt,right=1pt,top=1pt,bottom=1pt, colframe=gray,colback=gray!10, highlight math style={enhanced} % <--- } \renewcommand{\equiv}{;\tcbhighmath{=};}

\begin{document} $w - 2 \equiv v \equiv v$ \end{document}

Zarko
  • 296,517