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'm new to LaTeX. I'm trying to create a tabular and I'm facing various small issues.

I would like to create a tabular with two columns, the second one being multiline. I found out I can use p{} to achieve that, but the problem is that I now need to specify the width. I would have liked to set it as line width minus whatever space is used by the first column, but I don't know how to do that. edit: so I can use tabularx, but my problem now is that it goes beyond the end of the page:

\documentclass{article}
\usepackage[top=1in, bottom=1in, left=0pt, right=0pt]{geometry}%margins
\begin{document}
\begin{tabularx}{\textwidth}{|c|X|}a&b
\end{tabularx}
\end{document}
share|improve this question
3  
Welcome to TeX.sx! While your questions are all about tables, they cover fairly separate problems. Our rule here is to have only one problem per question. Please remove three of your problems from this question and post them as a new questions, after checking that they haven't been asked yet (no duplicates). This way, other users looking for help can find solutions more easily. Also don't forget to provide a minimal working example (MWE) for each question. –  doncherry Jun 9 '12 at 17:34
    
okay, done..... –  jlo17 Jun 9 '12 at 17:41
    
Thanks for breaking them up in to separate question. Can you also include compose a compilable MWE that illustrates the problem including the \documentclass and the appropriate packages. –  Peter Grill Jun 9 '12 at 17:43
    
done too........ –  jlo17 Jun 9 '12 at 17:46
    
Besides tabularx, as pointed out by @ScottH., you can use tabu, as demonstrated e.g. in this answer. The tabu package in my opinion offers a more convenient user interface. –  dgs Jun 9 '12 at 17:58
add comment

1 Answer

up vote 3 down vote accepted

Edited to reflect egregs suggestion which fixes your problem (at least on my end):


If I understand correctly, you can use the tabularx package for this.

\documentclass{article}
\usepackage{tabularx}
\usepackage{lipsum}
\usepackage[top=1in, bottom=1in, left=0pt, right=0pt]{geometry}
\begin{document}
\begin{table}
\centering
\begin{tabularx}{\textwidth}{c X}
    First Column& \lipsum[1]
\end{tabularx}
\end{table}

\end{document}

The syntax is \begin{tabularx}{<desired table width>}{<column spec>} where an X column specifier automatically adjusts the width of that column to fill space so that the entire table is of the desired table width.

share|improve this answer
    
Adding \noindent just before \begin{tabularx}, or inserting this in a table environment with \centering. –  egreg Jun 9 '12 at 17:51
    
I tried to use what you said, but it doesn't work, it goes beyond the end of the line, so much so that the entire tabular isn't displayed. I also tried linewidth instead of linewidth, it produces the same result. –  jlo17 Jun 9 '12 at 17:56
    
Sorry, I'm not sure what could be the problem. You copy pasted that code and it didn't work? –  Scott H. Jun 9 '12 at 18:06
    
No, I tried to adapt it to my situation, and that failed. Your code alone actually works. It seems that in my case, what causes it to fail is an incompatibility with another package that I have, which is: \usepackage[top=1in, bottom=1in, left=0pt, right=0pt]{geometry} –  jlo17 Jun 9 '12 at 19:41
    
Could you edit your original post to include the table that you are trying to make? If you include your document class and preamble (packages that you are loading etc.), then it's likely that someone can give you a better solution or point out the problem with this one :) Without having that information, it's hard to diagnose the problem. –  Scott H. Jun 9 '12 at 23:59
show 1 more 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.