28

I'm looking for some sort of vertical equivalent for \rlap, which can be used to typeset maybe one or more paragraphs (or minipages), but do not advance vertically the content that would appear immediately following this command. Are there anywhere some implementations of \tlap and \blap?

Juan A. Navarro
  • 62,139
  • 32
  • 140
  • 169

4 Answers4

21

Usually I define those by hand. I don't know any package that provides them. Roughly something like:

\documentclass{article}

\newcommand{\tlap}[1]{\vbox to 0pt{\vss\hbox{#1}}}
\newcommand{\blap}[1]{\vbox to 0pt{\hbox{#1}\vss}}

\begin{document}

\hrulefill\blap{\shortstack{haha\\huhu}}\hrulefill
\tlap{\shortstack{haha\\huhu}}\hrulefill\par

\end{document}
16

You can use \raisebox for this:

\raisebox{-\height}[0pt][0pt]{<content>}% blap
\raisebox{0pt}[0pt][0pt]{<content>}% tlap, without changing the baseline
\raisebox{+\depth}[0pt][0pt]{<content>}% tlap, with lapping it completely upwards

As Stephane pointed out you can also use \vbox to 0pt and \vss for this. See also my post and the discussion about this on comp.text.tex:
Vertical versions of \llap and \rlap: \tlap and \blap

I would write it now as follows to avoid any issues if used at the begin or between paragraphs:

\newcommand{\tlap}[1]{\mbox{\vbox to 0pt{\vss\hbox{#1}}}}
\newcommand{\blap}[1]{\mbox{\vbox to 0pt{\hbox{#1}\vss}}}
Martin Scharrer
  • 262,582
7

You can use \smash Here a small introduction: TUGboat, Volume 22 (2001), No. 4

Marco Daniel
  • 95,681
  • Thanks, that works but seems to be something like \tlap while I was looking for \blap. – Juan A. Navarro Jul 22 '11 at 18:36
  • This works similar like \tlap without changing the baseline, but not for \blap or for lapping it complete upwards including the depth. Good article BTW, I wanted to link to it as well. – Martin Scharrer Jul 22 '11 at 18:41
  • Just for information, the Tugboat article referenced in the answer was published in TUGboat Volume 22, Number 4, December 2001, on page 350. – mas Aug 05 '11 at 15:34
  • Reading the linked article leaves me wondering how come it doesn't mention \hidewidth at all. – morbusg Aug 06 '11 at 11:31
5

The just-submitted stackengine package has vertical lapping commands built into it. Furthermore, while the package defaults to a +/-\baselineskip vertical shift for the lap, that dimension may be tailored for your need.

In the example, below, I place a visible marker at the invocation site, so that you can see from where the lap is in reference to.

Hopefully, CTAN will propagate the package this weekend.

\documentclass{article}
\usepackage{stackengine}
\usepackage{verbatimbox}
\parindent 0in\parskip 1em
\fboxsep=0pt\fboxrule=.1pt
\def\lapmark{\rule[-.3\baselineskip]{.1ex}{\baselineskip}}
\begin{document}
For illustration only, laps will be shown at a \textit{visible} lapmark
(given by \lapmark~), defining the point of invocation.  In these
examples, I lap a \verb|\parbox| above or below the selected location.

\begin{myverbbox}{\bll}\bllap\end{myverbbox}
\begin{myverbbox}{\brl}\brlap\end{myverbbox}
\begin{myverbbox}{\tll}\tllap\end{myverbbox}
\begin{myverbbox}{\trl}\trlap\end{myverbbox}
\begin{myverbbox}{\bcl}\bclap\end{myverbbox}
\begin{myverbbox}{\tcl}\tclap\end{myverbbox}
For example here\lapmark%
\bllap{\parbox[t]{.7in}{this is a bottom-left lap \bll}}
or el\lapmark%
\brlap{\parbox[t]{.8in}{this is a bottom-right lap \brl}}%
se here, or else I can put it here\lapmark%
\tllap{\parbox[b]{.7in}{this is a top-left lap \tll}}
or here\lapmark%
\trlap{\parbox[b]{.7in}{this is a top-right lap \trl}}%
.

Of course, I can per\lapmark
\bclap{\fbox{\parbox[t]{1.1in}{this is a bottom-center lap \bcl}}}%
form center lapping, as we\lapmark%
\tclap{\fbox{\parbox[b]{1.1in}{this is a top-center lap \tcl}}}%
ll.

\end{document}

enter image description here