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 am using a resume template I found here - http://www.davidgrant.ca/latex_resume_template

There is a custom command, based around the tabular environment, which is in the MWE below. I would like to be able to start a new line in the first argument, but I am unsure how to do this (currently \newline does nothing, whilst \ or \* just breaks the compilation)

MWE:

 \documentclass[letterpaper,11pt]{article}

 \newcommand{\ressubheading}[4]{
 \begin{tabular*}{6.5in}{l@{\extracolsep{\fill}}r}
         \textbf{#1} & #2 \\
         \textit{#3} & \textit{#4} \\
 \end{tabular*}\vspace{-6pt}}

 \begin{document}

 \ressubheading{A very long piece of text that I wish to break\newline over two lines goes here}{Some other reasonably long piece of text}{Less tex    t}{Less text}

 \end{document}
share|improve this question

2 Answers 2

up vote 2 down vote accepted

Something like this. Here the l column specifier is redefined to be L that has p(0.5\textwidth) for a paragraph style that is raggedright/left alignment. By the same idea, one can change the r column specifier to R that has raggedleft/right alignment for a paragraph style.

enter image description here

Code

\documentclass[letterpaper,11pt]{article}
\usepackage[margin=10pt,paper size={20cm,5cm}]{geometry}
\usepackage{array}
\renewcommand*{\arraystretch}{1.5}
\newcolumntype{L}{>{\raggedright\arraybackslash}p{0.5\textwidth}}

 \newcommand{\ressubheading}[4]{
 \begin{tabular*}{6.5in}{L@{\extracolsep{\fill}}r}
         \textbf{#1} & #2 \\
         \textit{#3} & \textit{#4} \\
 \end{tabular*}\vspace{-6pt}}

 \begin{document}

 \ressubheading{A very long piece of text that I wish to break\newline over two lines goes here}{Some other reasonably long piece of text}{Less tex    t}{Less text}

 \end{document}
share|improve this answer
    
That's great, works perfectly, thank you. Just to check, if I want to apply this to the text on the right as you suggest, is the only change to be made in the fifth line of your code, changing raggedright to raggedleft (as well as the appropriate "r" and "l" substitutions) –  Joe Tait Jul 26 at 14:32
    
Yes, correct, the fifth line and use capital R to be unique. –  Jesse Jul 26 at 14:35
    
One should probably replace {L@{\extracolsep{\fill}}r} with {@{}L@{\extracolsep{\fill}}r@{}} in order to avoid the insertion of whitespace (in the amount of \tabcolsep) to the left of the first column and the right of the second column, right? –  Mico Jul 26 at 14:39
    
Sure, but the setting p(0.5\textwidth) is also another options for changes, right? –  Jesse Jul 26 at 14:46
    
Not really -- unless \tabcolsep has been set equal to 0pt. Setting the width of the first column to p{0.5\textwidth} and using @{\extracolsep{\fill}} to insert whitespace between the two columns does not affect the automatic insertion of whitespace (in the amount of \tabcolsep) to the left of the first column and to the right of the final column. –  Mico Jul 26 at 15:09

In the definition of \ressubheading, you may want to replace the tabular* environment and the l and r column types with a tabularx environment and raggedright and raggedleft variants of the X column type.

Note that X-type columns are all equally wide by default; if you want to change that, say to make the left-hand column a bit wider than the right-hand column, check out the instructions in the user guide of the tabularx package.

Since it looks like you want the table to occupy the full width of the text block, I have two additional recommendations. First, don't use a fixed width -- such as 6.5in -- for the tabular[x*] environment. Instead, set the environment's width to \textwidth; that way, its width will be determined by LaTeX automatically. (This is particularly useful if \textwidth is not equal to 6.5in...) Second, use \noindent prior to \begin{tabular[x*]} -- especially if \parindent is non-zero in your document.

enter image description here

\documentclass[letterpaper,11pt]{article}
\usepackage[margin=1in]{geometry} % choose page margins here
\usepackage{tabularx,ragged2e}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\newcolumntype{R}{>{\RaggedLeft\arraybackslash}X}

\newcommand{\ressubheading}[4]{%
   \noindent
   \begin{tabularx}{\textwidth}{@{}LR@{}}
         \textbf{#1} & #2 \\
         \textit{#3} & \textit{#4} \\
   \end{tabularx}%% \vspace{-6pt} % is \vspace macro needed?
}
\usepackage{lipsum}  % for filler text
\begin{document}

\ressubheading{A very long piece of text that I wish to break over two lines goes here}%
{Some other reasonably long piece of text}{Less text}{Less text}

\medskip
\lipsum[1]  % filler text
\end{document}
share|improve this answer
    
Thank you very much for the solution, and the additional advice, especially tabularx :) –  Joe Tait Jul 26 at 15:00
    
@Mico -- Sorry, It seems that I misunderstand your comment. –  Jesse Jul 26 at 15:43

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.