0

I would like to make a tabular with only 1 column. I want the tabular to have a fixed width and to contain several sentences. As some sentences may be long, several rows may be needed to hold 1 sentence. Here is what a tabular containing 3 sentences looks like (Sorry that I could not draw well the vertical and horizontal lines):

---------------------------
| Sentence 1 is very very |
| very very long.         |
---------------------------
| Sentence 2 is short.    |
---------------------------
| Sentence 3 is very very |
| very very very very ve- |
| -ry very long.          |
---------------------------

So I do not want to manually separate a sentence into several rows, I would like latex to do it, once the width of the tabular is specified. So the height of the tabular is up to the length of all the sentences...

Does anyone know if it is possible?

LaRiFaRi
  • 43,807
SoftTimur
  • 19,767
  • 1
    Please provide a minimal working example (MWE) of some kind. You have evidently been using this site for some time so you have some experience with TeX. Why can't you use an ordinary tabular with a p{} column? I'm not seeing the problem. – cfr Oct 26 '14 at 01:56
  • 1
    Well, not every question needs absolutely a MWE... I am asking for a solution to make what I expect (I made effort to draw it)... I am not asking to find a bug in an existing program. If you can explain more about that p{}, that would be much more helpful than a down-vote... – SoftTimur Oct 26 '14 at 02:00
  • 2
    Yes it does, I will provide an answer now, but I will have to type round about ten lines for you, which you could have typed. And maybe after that, you will say "oh no, sorry, I needed that in beamer". That's why we want an MWE. By the way, this topic has many answers here. – LaRiFaRi Oct 26 '14 at 02:04
  • 1
    Well every answer has to start with an MWE. So anybody who wants to help has to begin from scratch. You don't even provide the text you want in a document structure somebody can copy, paste and compile. As Peter Grill says, problems may be fun to solve but they are not fun to set up. You've asked 118 questions prior to this one. You should not need to be asked to provide an MWE. Also, you cannot know who down-voted. I often comment on questions where people down-vote without leaving any explanation. (But I did down-vote in this case, yes, and I stand by that decision.) – cfr Oct 26 '14 at 02:05
  • @LaRiFaRi I think you forgot the link. – cfr Oct 26 '14 at 02:06
  • Enormous numbers of questions show how to use tabulars. http://tex.stackexchange.com/questions/31508/flushleft-with-p-option-in-tabular has a simple example in the question. – cfr Oct 26 '14 at 02:10
  • Sorry guys, when you say "Yes it does" or "every answer has to start with an MWE", please double check the questions you have asked or the answers you have provided to see if there is any without MWE. Whether a MWE is necessary is up to the question, in most of the circumstances, it is necessary. But, I think here without a WME people could understand my question, and both my question and the possible answers fit this site. – SoftTimur Oct 26 '14 at 02:15
  • 1
    No one said we do not understand your question. But you got two answers here with round about 15 lines of code which someone wrote for you, for free. We do not want to set up some maybe-the-OPs-problem-containing-document but solve clearly defined problems. Your problem seemed so easy that we had to expect other problems here. (Side note: I just checked 10 of your questions. None has an MWE. There are very few problems where an MWE does not relieve the strain on volunteers) – LaRiFaRi Oct 26 '14 at 02:23
  • Now you are proposing to close this question, because people may make a little bit effort and find a solution of this question in the answer (and the question) of that question? (Please don't answer this, it is not a question...) – SoftTimur Oct 26 '14 at 02:43
  • I also looked at several of your questions. It seems that, in general, you expect others to make the effort because you choose not to do so. It is you who are asking for help. It is only courteous to those who are willing to help that you do as much as you can. The effort of setting up the problem should be yours as you are already asking volunteers to assist you by making the effort required to solve it. The voting to close is because it seems to be a duplicate. I don't see what that has to do with anything (except that you don't seem to have searched before posting either). – cfr Oct 26 '14 at 02:52
  • OK... There are several things I think about when I post a question: 1) Is my question clear, is the setting up enough to get people to help here? 2) Will the question and the possible answers be clear enough and useful for someone else? As long as these conditions are fulfilled, my question is valid here. I will thank the volunteers with vote, points (or eventually pay attention to their ID). – SoftTimur Oct 26 '14 at 03:01
  • People are not here to "do as much as they can" (otherwise, they could google or search in a book, they will always end up by finding a solution). This site works because it has a good mechanism to make a good balance between people who ask and people who give. – SoftTimur Oct 26 '14 at 03:11

2 Answers2

2

p columns are made for this:

% arara: pdflatex

\documentclass{article}
\usepackage{booktabs}
\usepackage{microtype} % for nice justifying in narrow columns

\begin{document}
\begin{table}
\begin{tabular}{p{3cm}}\toprule
Sentence 1 is very very very very long.\\\addlinespace
Sentence 2 is short.\\\addlinespace
Sentence 3 is very very
very very very very very very long.\\\bottomrule    
\end{tabular}
\end{table}
\end{document}

enter image description here

Hyphenation will be unnecessary in most cases, if you load microtype. If you need some, load \usepackage[english]{babel}.

If you prefer the column to be ragged right (can look better for short text pieces), you may search this site for the package array and add the \raggedright-command to each column you like.

LaRiFaRi
  • 43,807
1

Not too beautiful, but as a starting point...

\documentclass{article}

\begin{document}

\begin{tabular}{|p{5cm}|} % The value that  you need in place of 5cm
\hline
Sentence 1 is very very 
very very long.         \\
\hline
Sentence 2 is short.     \\
\hline
 Sentence 3 is very very 
 very very very very very very
very very very very very very long.    \\   
\hline
\end{tabular} 
\end{document}

enter image description here