9

I would like to produce a particular symbol represented by a capital letter with an uppercase index and an overline bar between small parenthesis. By looking on the web I found

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath,amssymb}
\usepackage{mathtools}

\begin{document}
\newcommand\brabar{\scalebox{.3}{(}\raisebox{-1.7pt}{$-$}\scalebox{.3}{)}}
\[
\overset{\brabar}{D}\phantom{}^{0}
\]
\end{document}

which produce something close to what I am looking for (not in a very elegant way). I would simply like to have the (-) overset symbol closer to the D capital letter. Is it possible to do that? Thank you very much in advance.

Wellow
  • 93

4 Answers4

11

You can use the stackengine package. Ignore all the commands in the example, I only used those to typeset a compact example.

The commands that are important for you are

% PREAMBLE
\newcommand\brabar{\scalebox{.3}{(}\raisebox{-1.7pt}{--}\scalebox{.3}{)}} 

% DOCUMENT
\stackon[.1pt]{<letter>}{\brabar}

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage{stackengine}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{pgffor}

\newcommand\brabar{\scalebox{.3}{(}\raisebox{-1.7pt}{--}\scalebox{.3}{)}}

\begin{document}
\newgeometry{textwidth=3.5cm}
\foreach \lett in {A,B,C,...,Z}{
\noindent\stackon[.1pt]{\lett}{\brabar}
}
\restoregeometry
\end{document}
Alenanno
  • 37,338
  • 1
    By using $ \stackon[.1pt]{D}{\brabar}\phantom{}^0$ I get what I wanted. Thank you. – Wellow Jan 05 '16 at 15:57
  • 1
    Out of curiosity, how well does this scale in text mode? Math mode sub/superscripts? – Sean Allred Jan 05 '16 at 21:06
  • @SeanAllred Sorry for the late reply. As in using \Huge? Not really. I'm trying to find a solution to that, maybe group the \brabar components so they scale together, but I'm not sure how to approach it. – Alenanno Jan 06 '16 at 11:40
5

With this code?

\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{accents}
\newcommand\brabar{\scalebox{.3}{(}\raisebox{-1.7pt}{$-$}\scalebox{.3}{)}}
\newcommand\brobor{\smash[b]{\raisebox{0.6\height}{\scalebox{0.5}{\tiny(}}{\mkern-1.5mu\scriptstyle-\mkern-1.5mu}\raisebox{0.6\height}{\scalebox{0.5}{\tiny)}}}}

\begin{document}

\[
\overset{\brabar}{D}\phantom{}^{0}
\]


\[
\accentset{\brobor}{D}\phantom{}^{0}
\]

\end{document} 

enter image description here

Bernard
  • 271,350
2

The main problem is that -- is asymmetrical and $-$ is contained in a very large box. One can demonstrate this using \fbox with \fboxsep=0pt.

\documentclass{standalone}
\usepackage{mathtools}
\newcommand\brabar{\scalebox{.3}{(}\raisebox{-1.7pt}{$-$}\scalebox{.3}{)}}

\newcommand\brabarb{\scalebox{.3}{(}\raisebox{-1.7pt}[0pt][0pt]{$-$}\scalebox{.3}{)}}

\begin{document}
$
\overset{\brabar}{D}\phantom{}^{0}  
\overset{\brabarb}{D}\vphantom{D}^{0}
$
\end{document}

overset

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
1

A version using TikZ (also not elegant but working, edited to make it appear "naturally" when used within a formula):

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath,amssymb}
\usepackage{mathtools}
\usepackage{tikz}

\begin{document}
\newcommand{\brabar}[2]{\tikz[baseline]{\node at (0,0.1) {#1};\node at (0,0.28) {\scalebox{.3}{(}\raisebox{-1.7pt}{$-$}\scalebox{.3}{)}};\node at (0.3,0.3) {\scriptsize #2};}}
\[
\brabar{D}{0}
\]
\end{document}

The output looks as follows: enter image description here

You can customize the positioning by adjusting the coordinates.

cryingshadow
  • 2,350
  • Thanks! Nice solution! Anyway if I use it in math mode instead of displaymath I get a vertical shift (example: $B^\pm \to K^\pm \brabar{D}{0}$). How can I fix that? – Wellow Jan 05 '16 at 15:45
  • @MVal I also noticed this and changed my code. Please try again. – cryingshadow Jan 05 '16 at 15:47