This is similar but hopefully not repetitive with other questions answered here... I want to use a straight line decoration above a formula to denote the mean value over observations. My main problems with \overline is that it is too light. I've tried the \bm option but it only seems to work with \bar, not \overline. It would also be great to slightly trim the \overline decoration as is done with the \overbar command, described in another answer on this forum
Asked
Active
Viewed 2,479 times
3
-
Welcome to TeX.SX! A tip: You can use backticks ``` to mark your inline code as I did in my edit. – Adam Liter Mar 09 '14 at 03:32
1 Answers
7
Obligatory tikzmark solution
\documentclass{article}
\usepackage{tikz}
\newcommand\tikzmark[1]{%
\tikz[remember picture,baseline] \node[inner sep=0,outer sep=0] (#1){\rule{0em}{1.75em}};%
}
\newcommand\Overline[3][line width=1pt]{%
\begin{tikzpicture}[remember picture,overlay]
\draw[#1] (#2.north east) -- (#3.north west);
\end{tikzpicture}
}
\begin{document}
\[
\tikzmark{A}A + B = C\tikzmark{B}
\]
\Overline{A}{B}
\[
\tikzmark{A}A + B = C\tikzmark{B}
\]
\Overline[line width=0.5pt]{A}{B}
\end{document}

Here is a lighter, macro form of the facility, that uses a node incorporating the suggestion given by egreg:
\documentclass{article}
\usepackage{tikz}
\newcommand\Overline[2][1pt]{%
\begin{tikzpicture}[baseline=(a.base)]
\node[inner xsep=0pt,inner ysep=1.5pt] (a) {$#2$};
\draw[line width= #1] (a.north west) -- (a.north east);
\end{tikzpicture}
}
\begin{document}
\[
\Overline[1pt]{A + B = C}
\]
\[
\Overline[0.5pt]{A + B} = C
\]
\end{document}

-
Can this solution be made into a macro that operates similar to
\overline? – cslstr Mar 09 '14 at 05:15 -
I'm not sure
\tikzmarkis really needed; can't you just draw a line above a TikZ node? – egreg Mar 09 '14 at 14:35 -
-