[texhax] Left aligning the maths environment
Steve Schwartz
s.schwartz at imperial.ac.uk
Thu Jul 27 01:13:41 CEST 2006
Jim,
Others on the list may provide more elegant answers, but...
I'm not sure exactly what you want, but I'd be inclined to use a tabular
environment rather than a maths array. Since the syntax is the same for
the actual entries ( separate by "&", terminate line with "\\" ), it's a
pretty trivial change to what you have.
Also, the capabilities of the array PACKAGE (not to be confused with the
array environment), give you control over lots more things, For example:
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{p{3em}|>{\tt}l<{\rm}|>{$}c<{$}}
23 & this is text & \alpha\ mathmode\ here \\
\end{tabular}
\end{document}
will set the 1st column entries in 3em-wide parboxes, will switch to tt
for the 2nd column, (then switch back to roman so as to preserve the
rest of your document), and set the contents in the 3rd column in math
mode. Does that do what you want?
By way of explanation:
p{3em} put the contents in a 3em-wide parbox
| a vertical bar - for clarity of the example only
>{\tt} put \tt in front of the contents of the 2nd col
l left justify the 2nd col
<{\rm} put \rm after the contents of the 2nd col
| another vertical bar
>{$} switch to math mode for col 3
c center the col
<{$} switch out of math mode
Note:
1) \verb and verbatim don't work inside a tabular environment (at least
I couldn't get it to, and there's a tex faq on verbatim which explains
why that might be so). This solution thus requires, for example, that
you manually specify any indentations in your code lines. There may be
clever ways to automate this.
2) \texttt and \textrm don't seem to work as declarators around the 2nd
column for some reason, probably because they need arguments, but the
generic \tt and \rm switches do. [I didn't find a way to pass a curly
brace as part of the declarator.]
Hope this helps... See
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=verbwithin
and
http://tex.loria.fr/ctan-doc/macros/latex/packages/tools/array.dvi
Steve
On Wed, 2006-07-26 at 21:50 +0100, James Smith wrote:
> 1) The first column contains line numbers and I'd like to make it a
> fixed width. I'm not bothered about the width of the remaining columns
> since the code and assertions that they contain is so variable. I just
> need to fix the first column
>
> 2) I'd like to move the whole lot hard over to the left, at the moment
> it floats in the middle. Is this possible without losing the use of
> the
> \array environment, which is ideal.
--
+-------------------------------------------------------------------+
Professor Steven J Schwartz Phone: +44-(0)20-7594-7660
Space and Atmospheric Physics Fax: +44-(0)20-7594-7772
The Blackett Laboratory E-mail: s.schwartz at imperial.ac.uk
Imperial College London Office: Huxley 6M70
London SW7 2BW, U.K. Web: http://www.sp.ph.ic.ac.uk/~sjs
+-------------------------------------------------------------------+
More information about the texhax
mailing list