Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to change my LaTeX table formatting slightly, but due to the way the documents are generated, I can't do so by changing the actual LaTeX code, but can change what will appear in the preamble.

The change I'd like to make is to have the 1st column width fitted to the text. I know this can be achieved from the LaTeX code from changing first the |L| to |l| (i.e making the l lower case)

\begin{tabulary}{\linewidth}{|L|L|}
table stuff
\end{tabulary}

But is there any way that this can be made the default case by changing something in the preamble?

Also, a second question, though less important, is about if it's possible to have a very long string (longer than column width) wrapped around to the next line. Because at the moment I have a hyperlink in a column which ignores the column boundary and just juts out.

If anyone can help with wither or both of these I'd be grateful.

share|improve this question
1  
After loading tabulary, you can issue \newcolumntype{L}{l} to redefine the L-column type to be the same as l. In order to allow wrapping of column content, you need to use a p{<len>} column type (which will be left-aligned for non-wrapping text). Here <len> is a known length (like 5cm, for example). So, perhaps using a straight L -> p{<len>} replacement would suffice. –  Werner Jul 13 '12 at 19:37
    
Welcome to TeX.sx! Your answer was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or edit your answer. –  Martin Schröder Jul 14 '12 at 21:10
    
Are all the tabulary environments of that form? –  egreg Jul 14 '12 at 21:25
1  
Related Question: How to separate table content and table style. –  Peter Grill Jul 14 '12 at 23:15
    
@Werner Thanks! I've tried using the newcolumntype{L}{l} command, which does the trick on the second column of one of the two column tables in my document. However, I want the first column to be formatted like this. But using \newcolumntype{l}{L} throws up a bunch of ! Missing # inserted in alignment preamble. errors. I also have a 3-column table in the same document - the first two columns of which I'd like to be fitted to the text. Do you know of any way of making it so that all but the last column of any table (with any no. of columns) has text fitted to the column width? –  user1488804 Jul 16 '12 at 10:02
add comment

migrated from stackoverflow.com Jul 14 '12 at 21:07

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 0 down vote accepted

It turns out that the answer to my problem isn't in using the latex preamble (so this thread may no longer be relevant to this website), but with Sphinx - the program I am using to create my documentation.

It supports a .. tabular columns:: directive that lets you control column widths of individual tables by using this in you rst formatted text.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.