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.

How to make this kind of tabbed paragraph: 3 columns 2cm 10cm 2cm, the last column is right aligned and it's content starts on the last line of the paragraph of the second column.

10.      Some text or description here 
         can has more than one line           300

This is what I have so far:

\documentclass[10pt,a4paper]{report}
\begin{document}
\begin{tabular}{p{2cm}p{10cm}p{2cm}}
10. &
Some text or description here can has more than one line &
\raggedleft{300} \\
\end{tabular}
\end{document}

I dont know how to vertically align last column

share|improve this question
1  
Welcome to TeX.SX! Please make your code compilable, starting with \documentclass{...} and ending with \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to help you. Help them help you: remove that one hurdle between you and a solution to your problem. –  Jubobs Aug 19 '13 at 11:00
    
I've edited the code –  spajak Aug 19 '13 at 11:26
1  
This seems to be the answer you are looking for tex.stackexchange.com/a/6496/31058 –  Ludovic C. Aug 19 '13 at 11:46
    
possible duplicate of Problem with Table Vertical Alignment –  lockstep Aug 19 '13 at 11:55
    
Estimating paragraph height is not the solution –  spajak Aug 19 '13 at 12:03

2 Answers 2

up vote 6 down vote accepted

It's probably easiest to make the final part part of the main paragraph so it naturally aligns with the last row. Exactly how to do that depends a bit on whether it needs to be multiple line or not, but for example

enter image description here

\documentclass[10pt,a4paper]{report}
\setlength\textwidth{16cm}
\begin{document}
\begin{tabular}{p{2cm}p{10cm}p{2cm}}
10. &
Some text or description here can has more than one line 
Some text or description here can has more than one line 
\hfill 300\hspace{-2cm}\mbox{}\\
\end{tabular}
\end{document}
share|improve this answer
    
It works. But what is mbox{} for? –  spajak Aug 19 '13 at 12:07
    
@spajak latex tabular code trims white space from the start and end of the cell so the negative hspace would get removed by an \unskip if it was right at the end of the cell. –  David Carlisle Aug 19 '13 at 12:09
    
You probably want to accommodate for the \tabcolsep as well. –  Werner Aug 19 '13 at 13:04
    
@Werner perhaps or perhaps you just want \hspace{-any length big enough to stop latex complaining about overful box} the exact amount doesn't make any difference in most cases. –  David Carlisle Aug 19 '13 at 13:05

this looks very much like a toc entry.

i find that it's easier to think of this as a centered (block) paragraph, with the first element sticking out to the left, and the last element sticking out to the right. i also find it's easier to code this as a delimited macro, plain-style. here is a definition that has withstood the test of time.

\documentclass[12pt]{report}
\newdimen{\mylistindent}
\setlength\mylistindent{2cm}
\def\listline #1\\#2\\#3\par{%
  \begingroup
    \rightskip\mylistindent
    \noindent\hangindent\mylistindent
    \hbox to\mylistindent{\ignorespaces #1\hfil}%
    \ignorespaces #2\hfill\rlap{\kern\mylistindent\llap{#3\unskip}}%
    \par
  \endgroup
}

\pagestyle{empty}
\begin{document}

\listline 10\\
   Some text or description here can have more than one line.
   Some text or description here can have more than one line.\\
   200
\par

\noindent Here is some more text that is more than one line to
show that the formatted line stretches out to both margins.

\end{document}

output from example code

share|improve this answer

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.