5

I met a problem in equation editing:

enter image description here

The problem is that the underline is too long comparing with the bar over the letter. So I am wondering is there any symbol like \underbar so that I can get a bar under the characters which is of the same length as the over bar.

1
  • $$\underbar$$ why doesn't it work here? is it possible to put it in math exchange somehow? Sep 27, 2018 at 0:14

2 Answers 2

2

You can use a tikz-based solution: Play around with the distances to achieve the desired look. I personally would shift the overline a bit to the right because of the slanting of the math font.

\documentclass{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand{\tikzul}[2][2pt]{
\tikz[baseline=(content.base)]{
    \node(content)[inner sep=0pt]{$#2$};
    \draw($(content.south west)+(#1,-1pt)$)--($(content.south east)-(#1,1pt)$);
}
}   
\newcommand{\tikzol}[2][2pt]{
    \tikz[baseline=(content.base)]{
        \node(content)[inner sep=0pt]{$#2$};
        \draw($(content.north west)+(#1,1pt)$)--($(content.north east)-(#1,-1pt)$);
    }
    }
\begin{document}
0: $
\tikzul[0pt]{\tikzol[0pt]{K}}*\tikzul[0pt]{\tikzol[0pt]{D}} = \tikzul[0pt]{\tikzol[0pt]{E}}$, 1:
$\tikzul[1pt]{\tikzol[1pt]{K}}*\tikzul[1pt]{\tikzol[1pt]{D}} = \tikzul[1pt]{\tikzol[1pt]{E}}$, 2: 
$\tikzul{\tikzol{K}}*\tikzul{\tikzol{D}} = \tikzul{\tikzol{E}}$

\end{document}

Under and overlines

1
  • 1
    $$\underbar$$ why doesn't it work here? is it possible to put it in math exchange somehow? Sep 27, 2018 at 0:14
1

If you use \overline instead of \bar the lines will appear more even.

ETA: The \doublebar macro

\newcommand{\doublebar}[2][0]{\skew#1\bar{\textit{\b #2}}}

will perform the trick I mentioned in the comment; the optional argument is the skew factor for the top bar. E.g., \doublebar{F} or \doublebar[7]{F}.

3
  • Thanks @Jon. Actually, I want the underline to be smaller. It looks wierd like that using an underline. Do you have any idea?
    – user123
    Dec 12, 2015 at 3:34
  • @David There's the Plain TeX \b, but that's reserved for text mode. Something like \skew5\bar{\textit{\b K}} will do the trick. I put in a skew to make the bars look more in-line with each other.
    – Jon
    Dec 12, 2015 at 3:59
  • $$\underbar$$ why doesn't it work here? is it possible to put it in math exchange somehow? Sep 27, 2018 at 0:14

You must log in to answer this question.

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