3

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

jordan
  • 31

1 Answers1

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}

enter image description here

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}

enter image description here