[OS X TeX] Squeezing text into boxes

Luis Sequeira lfsequeira at gmail.com
Fri Jul 18 04:32:48 EDT 2008

> Good Morning!
> I'm trying to create text in a box to simulate the buttons on a
> graphing
> calculator. I've read the sections in "Guide to LaTeX" and "More
> Math into
> LaTeX" about using \fbox and have been experimenting with that
> command. I've
> figured out how to get the text centered in a box of a specific
> width (not
> hard) but have been stumped on getting
> 1. A framed box of text of a specific width AND height (so it
> matches the
> graphing calculator button)
> and
> 2. The text squeezed into the specific sized box (don't want to flow
> out the
> ends.)
> I suspect the resolution to #1 is just something I've missed in all
> the
> documentation, but #2 seems tougher. I know I could individually
> adjust each
> bit of text for each button, but it would sure be nice to not have
> to do
> that.
> Any ideas, suggestions or comments about how I might be able to do
> these
> tasks?
> Thanks,
> Randy Scott
> Santiago Canyon College

I second the suggestion to use pstricks. It is easy create the boxes,  
color them and put the text in them. And you can easily scale anything  
to fit, as the OP pointed out.

I was able to draw a little calculator in pstricks in just a few  

[if you want to take a look at the result, see here: http://www.ptmat.fc.ul.pt/~lsequeir/calculator.pdf 

so feel free to use this and customize to your heart's content.

I began by defining a command to draw and place any calculator button.  
They can be of different sizes and colors, so the command expects this  
info in its parameters.

%a command to draw and place a calculator button


Now we can draw our little calculator in a pspicture, such as the  
following example (which yields the picture in the above link):



1) As always, when using pstricks, you must use "TeX & Ghostscript"  
instead of pdflatex.

2) Also, don't forget to


(I used multido in this example, but you can do without it and draw  
each button individually)

3) Feel free to email me privately if you need further assistance. I  
am on digest mode, and also possibly some details may not be of  
interest to most members.

4) As to the size of the text: you can \scalebox or \psscalebox or  
\psscaleboxto as needed; and, if necessary, make use of pstricks'  
clipping facilities.


Luis Sequeira

More information about the MacOSX-TeX mailing list