TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to represent, say, the closure of a set or the extended reals, e.g., $\bar{\mathbb{R}}$ but unfortunately this creates a bar that is much too small (horizontally) and can barely be seen. On the other hand, $\overline{\mathbb{R}}$ creates a line that is too long. I need something that's just right, in between the bar and the overline. What would be my best choice?

share|improve this question
4  
See also this answer of mine for a \widebar command that produces a bar wider than \bar and smaller than \overline. – Hendrik Vogt May 13 '13 at 12:25
    
Related Question: Overline thickness. – Peter Grill Aug 23 '14 at 16:25
up vote 39 down vote accepted

Here is a command \xoverline[width percent]{symb} that will do it. Note that it will not scale inside sub or superscripts. If you need that, everthing has to go through a \mathchoice resulting in a lot more complex code.

\documentclass{article}
\usepackage{amsmath,amssymb}
\makeatletter
\newsavebox\myboxA
\newsavebox\myboxB
\newlength\mylenA

\newcommand*\xoverline[2][0.75]{%
    \sbox{\myboxA}{$\m@th#2$}%
    \setbox\myboxB\null% Phantom box
    \ht\myboxB=\ht\myboxA%
    \dp\myboxB=\dp\myboxA%
    \wd\myboxB=#1\wd\myboxA% Scale phantom
    \sbox\myboxB{$\m@th\overline{\copy\myboxB}$}%  Overlined phantom
    \setlength\mylenA{\the\wd\myboxA}%   calc width diff
    \addtolength\mylenA{-\the\wd\myboxB}%
    \ifdim\wd\myboxB<\wd\myboxA%
       \rlap{\hskip 0.5\mylenA\usebox\myboxB}{\usebox\myboxA}%
    \else
        \hskip -0.5\mylenA\rlap{\usebox\myboxA}{\hskip 0.5\mylenA\usebox\myboxB}%
    \fi}
\makeatother
\begin{document}

$|\xoverline{W}|~~
 |\xoverline{i}|~~
 |\xoverline[3.0]{i}|$

\bigskip

$\bar{\mathbb{R}}~~\overline{\mathbb{R}}~~\xoverline{\mathbb{R}}$

\end{document}

enter image description here

share|improve this answer
1  
Wow, I never knew this would be so involved! Very nice answer though and thanks for your help. – 3Sphere Jul 2 '11 at 13:08
2  
Someone should do the \mathchoice thing and package this into a package! – Mariano Suárez-Alvarez Jun 27 '14 at 5:38

I usually define a command \overbar, which reduced the width of \overline by 1.5mu on each side.

\documentclass{article}

\usepackage{amsfonts}

\newcommand{\overbar}[1]{\mkern 1.5mu\overline{\mkern-1.5mu#1\mkern-1.5mu}\mkern 1.5mu}

\begin{document}
$\bar{\mathbb{R}}$ $\overbar{\mathbb{R}}$ $\overline{\mathbb{R}}$
\end{document}

Output

share|improve this answer
1  
Would this solution have the same issues regarding subscripts/superscripts as described in Danie's solution? – Anthony Mottaz Jan 24 at 21:48

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.