1

I'm producing a series of flash cards in LaTeX (well, actually XeLaTeX). Each card has a title, a short paragraph of text, and a table, which is the main purpose of the card. Occasionally the paragraph references a footnote (which is laid out in the normal way at the foot of the card). The tables all occupy the same vertical height, but the paragraph above and the footnotes below (if present) can take up varying amounts of space.

I want to lay out the cards so the table appears in the same vertical position on each card, regardless of how much text there is above or below. Because of the way I'm generating the cards, I have very limited control over the LaTeX source, but unlimited control over the .sty file. In particular, I cannot wrap the table in a \textblock (e.g. as per this question). What I really want is a way of doing \vspace to 4cm, i.e. with an absolute page offset. Is anything like this possible?

  • You "cannot wrap the table in a \textblock". Okay, what else can you not do? Can you wrap the tabular inside something else? What about wrapping the paragraph in something? It would be ideal if you could identify all restrictions/limitations as well as some sample (compilable) code to work with. – Werner Dec 4 '18 at 23:41
  • The constraint is that I can only insert code before the table, but I cannot put anything after the table, not an \end{something} or even a single close brace. I have (almost) complete control over the formatting of the title and paragraph, and can wrap these in something if that helps. If there's an environment that turns the paragraph into a fixed-height box, I can easily use that, so long as it doesn't alter the paragraph indentation. – richard Dec 4 '18 at 23:48
  • Could you add an example of the code you have to manage? – egreg Dec 5 '18 at 0:19
2

You can set the paragraph inside a \parbox[<pos>][<height>]{<width>}{<stuff>} where <pos> is set to top, <width> is fixed at \linewidth and you specify something in <height> that accommodates all the paragraphs. Here's an example that uses 20\baselineskip (to fit 20 lines of text):

enter image description here

\documentclass{article}

\usepackage{geometry,lipsum}

\geometry{
  papersize = {6in,5in}, % A flash card
  margin = 0.5in
}

\setlength{\parindent}{0pt}
\newlength{\parboxheight}
\setlength{\parboxheight}{20\baselineskip}

\begin{document}

\parbox[t][\parboxheight]{\linewidth}{%
  \strut
  \lipsum*[1]% Your paragraph here
  \strut
}

{\centering \texttt{tabular} here\par}

\clearpage

\parbox[t][\parboxheight]{\linewidth}{%
  \strut
  \lipsum*[2]% Your paragraph here
  \strut
}

{\centering \texttt{tabular} here\par}

\clearpage

\parbox[t][\parboxheight]{\linewidth}{%
  \strut
  \lipsum*[3]% Your paragraph here
  \strut
}

{\centering \texttt{tabular} here\par}

\clearpage

\parbox[t][\parboxheight]{\linewidth}{%
  \strut
  \lipsum*[4]% Your paragraph here
  \strut
}

{\centering \texttt{tabular} here\par}

\end{document}

Using minipage is also a possibility.

  • Perfect. Thanks. I hadn't realised \parbox had an optional height parameter. – richard Dec 5 '18 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.