2

In mathmode, is there a way to underline a veriable that doesn't make the underline join to the next variable? Example:

\underline{X}\underline{Y}

except I want a break in the underline between X and Y.

the way i'm doing it now is comersome:

\text{ }\underline{X}\text{ }\underline{Y}

would be nice if there were a way to get an underline that is shorter and centers on the character so i doesn't bleed to the edge of the next character. because I'm trying to write matrix equations that have many vector variables marked with underlines...

5
  • \underline{X}\,\underline{Y}. But do you really need underlining? That was used when typewriters had very limited features.
    – egreg
    Commented Sep 3, 2020 at 15:49
  • yes because I can't use \vec{X} in the matrix equations because its too ugly and messy... thus, I want to move the bar below the variable and remove the arrow... it i don't mark them as vectors then it gets confusing to distinguish between scalars and vectors....and I can't use bold face either because my eyes can't see bold face vs. normal characters....
    – pico
    Commented Sep 3, 2020 at 15:50
  • I'd use \mathbf{v} or \bm{v} for vectors.
    – egreg
    Commented Sep 3, 2020 at 15:51
  • sorru, can't use that... its too hard for me to read bold face verse normal text...
    – pico
    Commented Sep 3, 2020 at 15:51
  • \underbar{X}\underbar{Y} except it doesn't work for me...
    – pico
    Commented Sep 3, 2020 at 16:18

1 Answer 1

4

Underlining is ugly. You can somehow mitigate it by shortening the underline:

\documentclass{article}
\usepackage{amsmath}

\renewcommand{\vec}[1]{%
  \mspace{2mu}%
  \underline{\mspace{-2mu}#1\mspace{-2mu}}%
  \mspace{2mu}%
}

\begin{document}

$\alpha\vec{X}\vec{Y}$

$\alpha XY$

\end{document}

The second line is for comparison.

enter image description here

Another strategy could be using accents:

\documentclass{article}
\usepackage{amsmath,accents}

\renewcommand{\vec}[1]{\underaccent{\bar}{#1}}

\begin{document}

$\alpha\vec{X}\vec{Y}$

$\alpha XY$

\end{document}

enter image description here

My preference would go to \bm:

\documentclass{article}
\usepackage{amsmath,bm}

\renewcommand{\vec}[1]{\bm{#1}}

\begin{document}

$\alpha\vec{X}\vec{Y}$

$\alpha XY$

\end{document}

enter image description here

In any case use proper markup. You might not want to redefine \vec and use a different command name. This way, you can change the appearance of all vectors by just changing the definition.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .