5

I would like to add indices as subscripts and superscripts to a couple of bounds denoted by underline (lower bound) and overline (upper bound), but I am not able to keep the same well-shaped look of the overall symbol, since the superscript is raised and the subscript is lowered with respect to the symbol not underlined/overlined (so that the resulting formula exceeds the textstyle space). Am I doing something wrong?

PS: The same problem affects only the subscript when used together with a superscript:

\[ \theta_k \; \underline \theta_k \]
\[ \theta^{\delta} \; \overline \theta^{\delta} \]
\[ \theta_k \;  \theta^{\delta} \; \theta_k^{\delta}\]

enter image description here

0

2 Answers 2

3

This still doesn't take care of line 3 (combined sub/superscript), but it does remedy the under/overline issue. I personally do not find the line 3 issue objectionable.

\documentclass{article} 
\newcommand\uletter[1]{\vphantom{#1}\smash{\underline #1}}
\newcommand\oletter[1]{\vphantom{#1}\smash{\overline #1}}
\begin{document}
\[ \theta_k \; \uletter{\theta}_k \]
\[ \theta^{\delta} \; \oletter{\theta}^{\delta} \]
\[ \theta_k \;  \theta^{\delta} \; \theta_k^{\delta}\]
\end{document}

enter image description here

2
  • thank you, this works perfectly. As regards the 'third line', I am aware that Latex has to process the whole formula in order to get a cleaner output; what puzzles me is the fact that, at least in principle, there is enough space for both subscripts and superscripts, so the overall layout is a little bit odd or too stretched out (maybe this is due to the skew positioning of the theta character). Can I ask you which is the combined role of \vphantom and \smash in your solution?
    – Vexx23
    Dec 31, 2016 at 16:16
  • @Vexx23 The \smash says to treat its argument as if it had zero height, effectively removing the \overline and \underline from affecting the script placement. The \vphantom says to insert a zero-width nothing, but which occupies the same vertical footprint as its argument. Thus, a nothing the size of a \theta is placed, followed by something which is treated as zero height, but has the desired appearance of a barred-theta. Dec 31, 2016 at 17:13
3

In my opinion, the \underaccent{\bar} command, or \underaccent{\widebar}, borrowing the \widebar symbol from mathabx, looks better, because it takes into account the italic angle of the glyphs:

\documentclass{article}
\usepackage{amsmath, accents}%

\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{
<5><6><7><8><9><10>
<10.95><12><14.4><17.28><20.74><24.88>
mathx10
}{}
\DeclareSymbolFont{mathx}{U}{mathx}{m}{n}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\DeclareMathAccent{\widebar}{0}{mathx}{"73}

 \newcommand\utheta{\vphantom{theta}\smash{\underline \theta}}
\newcommand\otheta{\vphantom{theta}\smash{\overline \theta}}

\begin{document}

\[ \theta_k \; \utheta_k \;\underaccent{\bar}{\theta}_k\;\underaccent{\widebar}{\theta}_k\]
\[ \theta^{\delta} \; \otheta^{\delta} \;\bar{\theta}^{\delta} \;\widebar{\theta}^{\delta} \]

\end{document} 

enter image description here

1
  • third and fourth outputs are by far cleaner, it is something one realizes only when seen up close.
    – Vexx23
    Jan 2, 2017 at 11:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .