5

I'm trying to define a memoir's \fancybreak taking a vertical space of, say, 2\baselineskip (or any other exact amount of \baselineskip).

But I have a problem with the height: if I do

\documentclass[twocolumn]{memoir}
\usepackage{lipsum}

\parindent=0pt

\begin{document}

\lipsum[1-4]

\vbox to 2\baselineskip{
\vspace*{\fill}
\centering *
\vspace*{\fill}
}

\lipsum[2]

\end{document}

I get a space of something more than 2\baselineskip:

enter image description here

Why? Which approach would you suggest?

2 Answers 2

5

Positioning vertical boxes can be tricky, it's easier to use horizontal boxes, which more naturally stay on the line grid.

enter image description here

\documentclass[twocolumn]{memoir}
\usepackage{lipsum}

\parindent=0pt

\begin{document}

\lipsum[1-4]

\noindent
\mbox{}\\[-.5\baselineskip]
\makebox[\linewidth]{*}\\[-.5\baselineskip]
\mbox{}

\lipsum[2]

\end{document}
2
  • 1
    The * is naturally raised, you may prefer $*$ to get a centred * Commented Jun 17 at 14:05
  • Thanks a lot. Since I don't have any maths in my document, I've seen that \textasteriskcentered has the same effect, without need of setting a math font. Commented Jun 17 at 14:29
3

Using David's idea, I create n horizontal boxes. In the last one I insert a zero height \vbox, which in turn contains the material to be vertically and horizontally centered. The asterisks are those of math mode, so we can lower them by the axis height and smash them.

Some additional vertical space has to be added before the material, because of the gap between the baseline of the last \hbox and the text in the following line. I used \dp\strutbox, which seems to provide a decent centering (the wye will not be misled anyway).

\documentclass[twocolumn]{memoir}
\usepackage{lipsum}
\usepackage{xcolor}

\ExplSyntaxOn

\NewDocumentCommand{\interruption}{mm}
 {% #1 = number of lines
  % #2 = material to be centered
  \par
  \prg_replicate:nn { #1 - 1 } { \hbox:n { } }
  \hbox:n
   {
    \vbox_to_zero:n
     {
      \vss
      \vbox_to_ht:nn { #1\baselineskip }
       {
        \vfil
        \vspace{\dp\strutbox}
        \hbox_to_wd:nn { \linewidth } { \hfil #2 \hfil }
        \vfil
       }
     }
   }
 }

\ExplSyntaxOff

% asterisks centered on the baseline
\NewDocumentCommand{\asterisks}{}{%
  \sbox{0}{$ $}\raisebox{-\fontdimen22\textfont2}[0pt][0pt]{${*}{*}{*}$}%
}

% this will show the baseline
\newcommand{\debugrule}{\makebox[0pt]{%
  \color{red}\vrule width 3\textwidth height 0pt depth 0.3pt}%
}

\begin{document}

\lipsum[1]

\interruption{3}{\asterisks}

\debugrule
\lipsum[2-4]

\interruption{2}{\asterisks}

\debugrule
\lipsum[2]

\end{document}

enter image description here

With \debugrule I show that the baselines in the two columns agree.

1
  • That's amazing, thanks! In fact, I realised that my concrete use-case is more complicated: if the interruption happens to be at the start of a page, the space before the asterisk should be stripped. But this should be another post… (For my present need, I'm triying in quite basic way: elastic \vspace before and after a \textasteriskcentered). Commented Jun 18 at 9:49

You must log in to answer this question.

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