7

I am trying to do something like the following:

enter image description here

Does anyone have an example of a technique on how to do this? It needs to be centered in the middle of the paper like the $$ $$ environment and it would be a bonus if it can be labelled and referred to later on.

1
  • A “real world” example might help: how to manage the text that stands for the usual variables depends on its nature; is it long? Is it just two lines to be centered with respect to each other? – egreg Sep 29 '13 at 10:03
7

You can set the text inside a regular \parbox:

enter image description here

\documentclass{article}
\newcommand{\textbox}[3][c]{\parbox[#1]{#2}{\strut#3\strut}}
\begin{document}
\begin{equation}
  \left\{\textbox{2cm}{Here is some regular text}\right\} =
    \left\{\textbox{2cm}{Here is some more regular text}\right\} +
    \left\{\textbox{3cm}{This is the last piece of text in the equation}\right\} \label{eqn:myeqn}
\end{equation}
See~(\ref{eqn:myeqn}).
\end{document}

\parbox[<valign>]{<width>}{<stuff>} sets <stuff> in a paragraph box of width <width> and aligned vertically according to <valign> (top, centered or bottom). The use of \struts at the start/end tries to rectify the spacing problem associated with boxing. As reference, see How to keep a constant \baselineskip when using minipages (or \parboxes)?.

The idea behind using a macro called \textbox is an attempt to promote typesetting consistency.

3
  • Thank you, perfect. If you can spare me some google, what is a "parbox" – masfenix Sep 29 '13 at 4:00
  • @masfenix: I've added some explanation. – Werner Sep 29 '13 at 4:11
  • the first line of the last element is terribly spacy. i think it would look better if the text in the boxes were ragged right or centered. (raggwed2e might be better than "ordinary" ragged right.) – barbara beeton Sep 29 '13 at 14:40

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.