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 work on a CV and I would like to write some content (e.g. conference information) on the left side of the page and a date on the right side of the page.

Because the content on the left side might be too long for one line: Is there a way to implement automatic line breaking while keeping the date after \hfill in the first line irrespective of how long the content on the left side is?

My example is:

\documentclass[11pt]{article} 
\usepackage[latin1]{inputenc}
\usepackage[left=1in,top=1in,right=1in,bottom=1in]{geometry}
\setlength{\parindent}{0in}

\begin{document}

{\Large \bf Conferences}

\centerline{Line 1, Line 1, Line 1, Line 1, Line 1, Line 1, Line 1, Line 1, Line 1, \hfill \textbf{Date}}
\centerline{Line 2. \hfill}

\end{document}

Is it possible to avoid using a second \centerline{}?

I prefer not using tables or CV templates.

I use MiKTeX 2.9.

share|improve this question
1  
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  Martin Schröder Feb 26 at 10:16

1 Answer 1

up vote 10 down vote accepted

You can define your own environment for this. There's space for improvements; for instance, you might want that the space reserved on the right is fixed for all items.

The \lipsum paragraphs are just to show how the environment's content is typeset with respect to the page margins.

\documentclass{article}
\usepackage{lipsum}

\newlength{\datumlen}
\newenvironment{datum}[1]
 {\settowidth\datumlen{\textbf{#1}}%
  \addtolength\datumlen{2em}% padding
  \list{}{\rightmargin=\datumlen\leftmargin=0pt}
  \item\relax\makebox[0pt][l]{\makebox[\textwidth][r]{\textbf{#1}}}\ignorespaces}
 {\endlist}

\begin{document}

\lipsum[2]

\begin{datum}{2013}
Some text describing what I want to describe, that will be
justified and automatically broken across lines, with space
reserved for the date on the right, which is printed
in boldface.
\end{datum}

\lipsum[3]

\end{document}

enter image description here

For a series of items, you can do like the following

\documentclass{article}
\usepackage{lipsum}

\newlength{\datumlen}
\newenvironment{data}[1]
 {\settowidth\datumlen{\textbf{#1}}%
  \addtolength\datumlen{2em}% padding
  \list{}{\rightmargin=\datumlen\leftmargin=0pt}}
 {\endlist}

\newcommand\dataitem[1]{%
  \item\relax\makebox[0pt][l]{\makebox[\textwidth][r]{\textbf{#1}}}\ignorespaces
}


\begin{document}

\lipsum[2]

\begin{data}{2013--current}% the argument is the widest label

\dataitem{2012} Some text describing what I want to describe, that will
be justified and automatically broken across lines, with space
reserved for the date on the right, which is printed in boldface.

\dataitem{2013--current} Again other text that should be broken across
lines and leave the correct amount of space on the right.
\end{data}

\lipsum[3]

\end{document}

enter image description here

share|improve this answer
    
I have a follow up question based on your solution. I tried to expand the code above to achieve a structure like \begin{datum}{widest date width} \item{text 1}{date 1} \item{text 2}{date 2} \end{datum} Text 1 and text 2 are meant to break automatically. It might be more flexible to define a new \item command instead of a new environment in order to avoid typing \begin{datum}{date} and \end{datum} again and again. However, I could not make it work. –  Matzipan Feb 26 at 16:03
    
@Matzipan I added the multiple item version –  egreg Feb 26 at 16:09
    
Now it is exactly what I need, so thank you again. –  Matzipan Feb 26 at 16:30

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.