2

Follow-up question to: Stretchable delimiters ignoring overline

Consider the following code:

$\left\{ f \right\} \; \left\{ \overline{f} \right\}$

The output in this case is not very satisfying, since braces in the right-hand example are extended to cover the overline, producing different brace height. In the mentioned question, a solution was proposed by @Steven B. Segletes:

\newcommand\noverline[1]{\vphantom{#1}\smash{\overline{#1}}}
$\left\{ f \right\} \; \left\{ \noverline{f} \right\}$

So far so good. Now I want to introduce an overline above the whole braced set, but the two overlines are typeset at the same height, so the outer one (which I would like to be slightly above) fully covers the inner one:

\newcommand\noverline[1]{\vphantom{#1}\smash{\overline{#1}}}
$\noverline{\left\{ f \right\} \; \left\{ \noverline{f} \right\}}$

Any clue how to obtain this? In the document I am currently typesetting I need to nest delimiters and overlines up to 3 levels, so I am afraid a one-shot solution will not cut it. Thanks in advance!

3
  • In my application, it is.
    – Jaeya
    Commented Jul 7, 2016 at 14:09
  • I don't know a simple, general fix, but the particular situation can be addressed by introducing a \vphantom exponent, as in $\noverline{\left\{ f \right\}^{\vphantom{x}} \; \left\{ \noverline{f} \right\}}$. Change the x to something else to affect the offset. Commented Jul 7, 2016 at 15:15
  • 1
    For something more general, a stackengine approach, such as \myoverline at tex.stackexchange.com/questions/167954/overline-thickness/… allows offsets to be specified, and may help you in this case. Commented Jul 7, 2016 at 15:22

2 Answers 2

2

Here I show it 5 times. 1st example shows the \left...\right problem, example 2 shows the fix for that from Stretchable delimiters ignoring overline.

The current problem is shown in example 3, with a \vphantom fix given in example 4 and the \myoverline fix in example 5,as referenced in Overline thickness, and modified to take an optional real number for the overline offset.

\documentclass{book}
\usepackage{stackengine}
\usepackage{scalerel}
\parskip 1ex \relax
\parindent 0pt\relax
\newcommand\noverline[1]{\vphantom{#1}\smash{\overline{#1}}}
\newcommand\myoverline[2][1.2]{\ThisStyle{%
  \setbox0=\hbox{$\SavedStyle#2$}%
  \stackengine{#1\LMpt}{$\SavedStyle#2$}{\rule{\wd0}{.4\LMpt}}{O}{c}{F}{F}{S}%
}}
\begin{document}
Original, with problem:\\
$\left\{ f \right\} \; \left\{ \overline{f} \right\}$

Referenced \verb|\noverline|:\\
$\left\{ f \right\} \; \left\{ \noverline{f} \right\}$

problem in current question:\\
$\noverline{\left\{ f \right\} \; \left\{ \noverline{f} \right\}}$

Vphantom superscript:\\
$\noverline{\left\{ f \right\}^{\vphantom{x}} \; \left\{ \noverline{f} \right\}}$

With \verb|\myoverline| and \verb|\noverline|:\\
$\myoverline[1.9]{\left\{ f \right\} \; \left\{ \noverline{f} \right\}}$
\end{document}

enter image description here

The net result is that we can now dispense with \overline and replace the reference to it in \noverline with \myoverline, so that \noverline can now take the optional argument of \myoverline (and works across math styles).

\documentclass{book}
\usepackage{stackengine}
\usepackage{scalerel}
\newcommand\noverline[2][1.2]{\vphantom{#2}\smash{\myoverline[#1]{#2}}}
\newcommand\myoverline[2][1.2]{\ThisStyle{%
  \setbox0=\hbox{$\SavedStyle#2$}%
  \stackengine{#1\LMpt}{$\SavedStyle#2$}{\rule{\wd0}{.4\LMpt}}{O}{c}{F}{F}{S}%
}}
\begin{document}
$\noverline[1.9]{\left\{ f \right\} \; \left\{ \noverline{f} \right\}}$

$\scriptscriptstyle\noverline[1.9]{\left\{ f \right\} \; \left\{ \noverline{f} \right\}}$
\end{document}

enter image description here

Note: If one wants the smaller math style overline to remain as thick as in display style (which is the case for the original \overline), then one need merely change the .4\LMpt length to .4pt, in the definition of \myoverline.

3
  • This works awesome, and it gave me quite a lot of insight on how to do a few other things. Thank you so much!
    – Jaeya
    Commented Jul 12, 2016 at 8:45
  • @Jaeya Glad to have been of some assistance. Commented Jul 12, 2016 at 10:15
  • I posted an answer below that automatically sets spacing.
    – Jaeya
    Commented Jan 13, 2022 at 10:29
0

Coming back to this 5 years later with a (IMHO) better answer; feel free to comment.

\tl_const:Nn \wine_log@olshrink {0.6mu}
\tl_const:Nx \wine_log@olshrinkfw {\exp_not:N \tex_mkern:D \muskip_eval:n {\wine_log@olshrink}}
\tl_const:Nx \wine_log@olshrinkbw {\exp_not:N \tex_mkern:D \muskip_eval:n {-\wine_log@olshrink}}
\dim_new:N \wine_log@olht
\dim_new:N \wine_log@olprev
\dim_new:N \wine_log@olnat
\dim_new:N \wine_log@oltemp
\box_new:N \wine_log@olbox
\box_new:N \wine_log@phantom

\cs_new:Npn \wine_log_overline:nn #1 #2 {
    \ensuremath{
        \group_begin:
        \dim_set:Nn \wine_log@olprev {\wine_log@olht}
        \dim_zero:N \wine_log@olht
        \dim_gzero:N \wine_log@oltemp
        \hbox_set:Nn \wine_log@olbox {\ensuremath {#2}}
        \dim_set_eq:NN \wine_log@olht \wine_log@oltemp
        \dim_set:Nn \wine_log@olnat {\box_ht:N \wine_log@olbox}
        \box_set_ht:Nn \wine_log@olbox {
            \dim_max:nn {\wine_log@olht} {\box_ht:N \wine_log@olbox}
        }
        \hbox_set:Nn \wine_log@olbox {
            \ensuremath {\wine_log@shortened_overline:n {\box_use_drop:N \wine_log@olbox}}
        }
        \dim_gset:Nn \wine_log@oltemp {
            \dim_max:nn {\wine_log@olprev} {\box_ht:N \wine_log@olbox}
        }
        \bool_if:nF {#1} {
            \box_set_ht:Nn \wine_log@olbox {\wine_log@olnat}
        }
        \box_use_drop:N \wine_log@olbox
        \group_end:
    }
}

\cs_new:Npn \wine_log@shortened_overline:n #1 {
    \wine_log@olshrinkfw
    \tex_overline:D {\wine_log@olshrinkbw #1 \wine_log@olshrinkbw}
    \wine_log@olshrinkfw
}
1
  • Could you state it more specifically?
    – M. Logic
    Commented Mar 2 at 15:58

You must log in to answer this question.

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