1

I'm recreating some mathematical notation from chapter 1 of Modern Classical Physics by Thorne and Blandford. I have a command \slot that creates a blank, underlined "slot" and that slot can itself contain exactly one additional "slot," drawn by the \smallslot command. The problem I need for the inner slot to be raised slightly above the outer slot. At present, as you can see below, the two "slots" overlap. I think the problem is that when \smallslot is used inside of \slot it too gets \smashed, which removes all of the vertical space, but that doesn't make complete sense to me due to the presence of the \mbox. How can I slightly raise the height of the inner "slot?" There will never be more than one inner and one outer "slot."

Here is my original MWE and its output.

\documentclass{article}
\usepackage{xparse}
\NewDocumentCommand{\slot}{ s O{~} }{%
  \IfBooleanTF {#1} % check for *
    {% * doesn't print a filled slot.
      %\,\smash{\makebox[1.5em]{\ensuremath{#2}}}\,
      {\ensuremath{#2}}
    }%
    {% Print a filled slot by default, a la Thorne and Blandford.
      \,\underline{\smash{\makebox[1.5em]{\ensuremath{#2}}}}\,
    }%
}%

\newcommand*{\smallslot}{\,\underline{\smash{\makebox[0.04em]{\ensuremath{~}}}}\,}

\begin{document}

\[
  \mathbf{a}(\slot) \qquad 
  %\mathbf{a}(\slot[\mathbf{b}]) \qquad 
  %\mathbf{a}(\slot[\mathbf{b}(\slot)]) \qquad 
  \mathbf{a}(\slot[\mathbf{b}(\smallslot)]) \qquad 
  %\mathbf{a}(\mathbf{b})
\]
\end{document}

Original compiled MWE results

EDIT: Per Donald Arseneau's suggestion, I removed \smash and here is the resulting MWE and its output.

\documentclass{article}
\usepackage{xparse}

\NewDocumentCommand{\slot}{ s O{} }{%
  \IfBooleanTF {#1} % check for *
    {% * doesn't print a filled slot.
      %\,\smash{\makebox[1.5em]{\ensuremath{#2}}}\,
      {\,\makebox[2.0em]{\ensuremath{#2}}\,}
    }%
    {% Print a filled slot by default, a la Thorne and Blandford.
      %\,\underline{\smash{\makebox[1.5em]{\ensuremath{#2}}}}\,
      \,\underline{\makebox[2.0em]{\ensuremath{#2}}}\,
    }%
}%

%\newcommand*{\smallslot}{\,\underline{\smash{\makebox[0.04em]{\ensuremath{~}}}}\,}
\newcommand*{\smallslot}{\,\underline{\makebox[0.80em]{\ensuremath{}}}\,}

\begin{document}
\[
  \mathbf{a}(\slot) \qquad 
  %\mathbf{a}(\slot[\mathbf{b}]) \qquad 
  %\mathbf{a}(\slot[\mathbf{b}(\slot)]) \qquad % Without the smaller slot.
  \mathbf{a}(\slot[\mathbf{b}(\smallslot)]) \qquad 
  %\mathbf{a}(\mathbf{b})
\]
\end{document}

Modified compiled output

I suspect the answer is going to be "no," but my new question is whether there is a way to make the outer slot's underline stay at the same height while the inner slot's underline is raised. As you can see, the exact opposite seems to now happen.

6
  • 1
    It is the \smash that prevents \underline from being "under" its argument. Aug 6, 2020 at 23:10
  • Aha! Okay I will attempt to fix that. Thank you very much. Aug 6, 2020 at 23:11
  • @DonaldArseneau That basically fixed the problem, but also raised an additional need for clarification. See edited question. Aug 7, 2020 at 0:27
  • Since you have different commands \smallslot versus \slot, it is in principle easy, but (a) why have separet commands?, and (b) you probably want the innermost "slot" to be at the baseline, and definitely NOT rased or lower any characters. Aug 8, 2020 at 9:39
  • Inner raise... as in the answer by @Cicada which raises characters? Or do you want the inner \slot to be raised to cross over characters? Or do you want only the empty slot to be raised? Aug 8, 2020 at 11:15

1 Answer 1

1

Manual adjustment with raisebox may help:

raisebox

Glyph depth (here, the bottom part of the ( and )) shifts the underline down.

What does the expected output look like, in Chapter 1?

Using the "dummy text" method, with and without (), gives:

brackets

MWE

\documentclass{article}
\usepackage{xparse}

\NewDocumentCommand{\slot}{ s O{} }{%
  \IfBooleanTF {#1} % check for *
    {% * doesn't print a filled slot.
      %\,\smash{\makebox[1.5em]{\ensuremath{#2}}}\,
      {\,\makebox[2.0em]{\ensuremath{#2}}\,}
    }%
    {% Print a filled slot by default, a la Thorne and Blandford.
      %\,\underline{\smash{\makebox[1.5em]{\ensuremath{#2}}}}\,
      \,\underline{\makebox[2.0em]{\ensuremath{#2}}}\,
    }%
}%

\newcommand*{\smallslot}{\,\underline{\makebox[0.80em][1ex]{\ensuremath{x}}}\,}

\begin{document}
\[
  \mathbf{a}(\slot) \qquad 
  \mathbf{a}(\slot[\raisebox{2.1pt}{$\mathbf{b}$(\smallslot)}]) \qquad 
\]
\end{document}

MWE variant

\documentclass{article}
\usepackage{xcolor}

\newsavebox{\slotboxname}
\begin{lrbox}{\slotboxname}{\textcolor{white}{(xxx}}\end{lrbox}%

\newsavebox{\slotboxnameb}
\begin{lrbox}{\slotboxnameb}{\textcolor{white}{(xx}}\end{lrbox}%

\newsavebox{\slotboxnamec}
\begin{lrbox}{\slotboxnamec}{\textcolor{white}{xxx}}\end{lrbox}%

\newsavebox{\slotboxnamed}
\begin{lrbox}{\slotboxnamed}{\textcolor{white}{xx}}\end{lrbox}%




\begin{document}

\[
a(\underline{\usebox{\slotboxname}}) = a(\underline{\raisebox{2pt}{b(\underline{\usebox{\slotboxnameb}})}})
\]

\[
a(\underline{\usebox{\slotboxnamec}}) = a(\underline{\raisebox{2pt}{b(\underline{\usebox{\slotboxnamed}})}})
\]


\end{document}

Actually, using \phantom{} would be more suitable than white text on white background, which latter is just to experimentally show that not all spaces are empty.

Acknowledgement: About lrboxes: One thing leads to another -- A question about quotchap (Place quote and chapter heading on separate pages with quotechap package) led to having a look in the .sty file.

1
  • Thank you very much. Let me study this to make sure I completely understand it. Aug 8, 2020 at 20:06

You must log in to answer this question.

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