开发者

LaTex - how to create boxes with fixed heights and widths, with enclosed text that is vertically and horizontally aligned?

This is for creating flashcards in LaTeX. My printer doesn't开发者_Go百科 support duplex printing - which packages like flashcards and flacards seem to require - so I am trying to create a two-column arrangement as follows on each page:

[Col1: Front side of the card] [Col2: Back side of the card]

Each row would correspond to a single flashcard. The plan is to cut each row up, fold them along the middle and staple them to create a "card".

The question: how best can I create a single box with a specified height and width, and with the text in it aligned vertically?

I am relatively new to Latex, so this cripples my options. I don't need full, detailed answers necessarily - any pointers at all in the right direction would help immensely! Any suggestions on alternative methods to achieve what I'm shooting for would also be helpful.

Many thanks!


Suppose you want to create the box of 40pt height and 3cm width:

\vbox to 40pt {\vfil
\hbox to 3cm{Some info}%
\vfil
}


You could use whatever packages to make your flashcards, and then save the output in pdf format (use pdflatex for example). Then, make another document in Latex which uses pdfpages package and uses its nup option to print two pages per page. Pdfpages has a lot of options, to fine-tune the page layout. That gives you all the power of the other packages for your use.


My TikZ-based solution with two scopes and nested fbox and parbox: text is horizontally (due to \centering) and vertically centered in the two boxes/columns, widths and heights may all be tuned.

\documentclass[tikz,multi=false,border=5mm]{standalone}
\usepackage{lipsum}

\begin{document}
\begin{tikzpicture}
\begin{scope}
  \node (0,0) {\fbox{\parbox[c][100mm][c]{65mm}{\centering%
    \lipsum[1]
  }}};
\end{scope}

\begin{scope}[xshift=75mm]
  \node (0,0) {\fbox{\parbox[c][120mm][c]{65mm}{\centering%
    Some text\\%
    \ \\%
    \lipsum[2]
  }}};
\end{scope}
\end{tikzpicture}
\end{document}

LaTex - how to create boxes with fixed heights and widths, with enclosed text that is vertically and horizontally aligned?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜