English 中文(简体)
LaTex - how to create boxes with fixed heights and widths, with enclosed text that is vertically and horizontally aligned?
原标题:
  • 时间:2010-01-09 17:12:05
  •  标签:
  • latex
  • tex

This is for creating flashcards in LaTeX. My printer doesn t 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}

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

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

screenshot of output





相关问题
Effective Version Control for Slides

I have to maintain a huge set of training material in forms of slides. At a first glance, I ve noticed there s no support for version control in OpenOffice OOImpress (but I might be wrong on this). ...

Maths in LaTex table of contents

I am trying to add a table of contents for my LaTex document. The issue I am having is that this line: subsubsection{The expectation of (X^2)} Causes an error in the file that contains the ...

Using vim s `gqap sometimes indents unusually

For the life of me, I cannot figure out the cause of this: when writing in LaTeX documents, I like to keep my line width to maximum of 80 characters. As such, I will execute the vim command gqap and ...

aligning math equations in Latex

I am trying to align the following equations around the equal sign. What can I do? Thanks! I am using the AMSMath package $$mddot{x}_{1}-K(x_{2}+x_{12})+C(dot{x}_{12}+dot{x}_{2})+2Cdot{x}_{1} ...

LaTeX output does not update

I have just begun using LaTeX. I am working in Windows and am using TeXnicCenter as my editor. When I build and output, having the following code: documentclass{article} egin{document} This is a ...

How to put line break in a math

I d like to express the following sentence (source_location is also italic, it s not correctly rendered): Each entry has a list of tuple: < source_location, R/W, trip_counter, occurrence, killed ...

热门标签