Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I used to fix the \overline command to get a conjugate complex number for I think the line does not so satisfy me by its length. You may noticed something like:

$$\overline{N}+\overline{F}+\overline{C}$$

could turn fine by:

$$\mkern3mu\overline{\mkern-3muN}
+\mkern3mu\overline{\mkern-3muF}
+\mkern2mu\overline{\mkern-2muC}$$

The \bar command don't have any profit in this situation.

How can I creat a command without cocerning the specific letter to get appropriate line width?

share|improve this question
add comment

1 Answer

You can try the following. It measures the difference in width between the upright (\mathrm) and the normal math character. The overline is set over a phantom box of the size of the upright symbol. It is then moved to the right with the difference in width between the two characters. It will work for super and subscripted symbols also

\documentclass{article}
\makeatletter
\newsavebox\tboxa
\newsavebox\tboxb
\newlength\tdima

\newcommand*{\oversymb}{\mathpalette\@oversymb}

\newcommand*{\@oversymb}[2]{%
    \sbox{\tboxa}{$\m@th#1\mathrm{#2}$}%
    \setbox\tboxb\null%
    \ht\tboxb\ht\tboxa%
    \dp\tboxb\dp\tboxa%
    \wd\tboxb\wd\tboxa%
    \sbox{\tboxa}{$\m@th#1{#2}$}%
    \setlength\tdima{\the\wd\tboxa}%
    \addtolength\tdima{-\the\wd\tboxb}%
    \sbox{\tboxb}{$\m@th#1\hskip\tdima\overline{\xusebox{\tboxb}}$}%
    \rlap{\usebox\tboxb}{\usebox\tboxa}}

\newcommand*{\xusebox}[1]{\mathord{{\usebox{#1}}}}

\makeatother
\begin{document}
\[\oversymb{N} + \oversymb{F} + \oversymb{C}\]
\[\oversymb{A} + \oversymb{a} + \oversymb{B} + \oversymb{b} + \oversymb{i}\]
\[x_{\oversymb{X}}\]
\end{document}

The result is

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.