3

I'm just Learning LaTeX and I don't know if there are better ways to do it, but I tried do do a nice CV layout using the description list and encountered the problem that when starting a newline within an item, an undesired indent appears.

I don't know how to align the new line to the margin without moving the first line of the item.

Here my code:

\documentclass{article}
\usepackage{enumitem}
\usepackage{setspace}
\doublespacing

\begin{document}

\begin{description}[align=right] %Title
\item[\underline{{\Large Title}}]  
\end{description}

\begin{description}[align=right] %Info
\item[Item 1] Some words
\item[Item 2] Other words
\item[Item 3] Different words 
\newline More words belonging to item 3

\end{description}

\end{document}

Here also a picture: enter image description here

Many thanks in advance!

P.S. is there any particular way of learning LaTeX that you recommend? e.g. some books guides or websites?

5
  • You can't have a description label right-aligned, unless you want it in the margin.
    – Bernard
    Commented Mar 24, 2017 at 12:14
  • For CVs there actually are quite nice templates by the way.
    – Skillmon
    Commented Mar 24, 2017 at 13:10
  • If you want to learn LaTeX search the internet for tutorials. Just make sure they are not too old. And take a look at the l2tabu: ctan.org/pkg/l2tabu (this is in german but there are links on the site for other languages). Else learning by doing is a good approach after you know the basics. Just try to do stuff and search here or elsewhere if you encounter problems you can't solve.
    – Skillmon
    Commented Mar 24, 2017 at 13:12
  • An overview of resources: tex.stackexchange.com/questions/11/…
    – cgnieder
    Commented Mar 24, 2017 at 13:45
  • Is my answer ok, or do you need something else? If so you might update your question clarifying stuff or comment on my answer.
    – Skillmon
    Commented Mar 24, 2017 at 16:36

2 Answers 2

2

Here is another possibility: another environment, rdescription, using eqparbox so that the labelwidth is the length of the longest label in the document:

\documentclass{article}
\usepackage{enumitem}
\usepackage[showframe]{geometry}
\usepackage{setspace}
\usepackage{eqparbox, etoolbox}

\newlist{rdescription}{description}{1}

\AtBeginEnvironment{rdescription}{%
\renewcommand*\descriptionlabel[2][Des]{\hspace\labelsep\eqmakebox[Des][r]{\hfill\normalfont\bfseries #2}}\setlist[rdescription]{leftmargin =\dimexpr\eqboxwidth{Des}+\labelsep}}%

\doublespacing

\begin{document}

  \begin{rdescription}%
    \item[Item 12000] Some words
    \item[Item 2] Other words
    \item[Item 250] Different words
    \newline More words belonging to item 3
  \end{rdescription}

\begin{rdescription}%
  \item[Item 1] Some words
  \item[Item 2] Other words
  \item[Item 250] Different words
  \newline More words belonging to item 3
\end{rdescription}

\end{document} 

enter image description here

4
  • Nice one. But there might be problems with very long labels. Other than that it really is a clean and nice solution.
    – Skillmon
    Commented Mar 24, 2017 at 17:20
  • I know about the problems. My solution for very long labels was the same as yours,so I didn't post it :o). There might a possibility to set a maximum for the label width so that longer labels split over lines, but I didn't have time to check in the doc of eqparbox.
    – Bernard
    Commented Mar 24, 2017 at 17:26
  • You might set a maximum and compare the results of \dimexpr\eqboxwidth{Des}+\labelsep with that. Then you decide whether to use your code or mine. Doesn't seem that hard to do. Reasonable maximum might be 0.5\textwidth.
    – Skillmon
    Commented Mar 25, 2017 at 8:07
  • Thank you both very much for the helpful and quick answers! This custom rdescriprionenvironment solved my problem :) Commented Mar 25, 2017 at 19:49
3

If I understand your question correct, you want to set the indentation of the rows after the first one of description-environments to 0cm. You might have a look at the enumitem-package. With it you can adjust and finetune the description lists. But I'd recommend the enumerate-environment:

\documentclass[]{scrartcl}
\usepackage{enumitem}
\begin{document}
Using \texttt{description}:
\begin{description}[leftmargin=0cm]
    \item[Item 1] Some words.
    \item[Item 2] Other words
    \item[Item 3] Different words\\More words belonging to item 3
\end{description}

Using \texttt{enumerate}:
\begin{enumerate}[leftmargin=*,label=\textbf{\sffamily Item \arabic*}]
    \item Some words.
    \item Other words
    \item Different words\\More words belonging to item 3
\end{enumerate}
\end{document}

The above code's output: results

EDIT: To get the labels in the description right aligned one might use:

\documentclass[]{scrartcl}
\usepackage{enumitem}
\begin{document}
Using \texttt{description}:
\begin{description}[align=right,leftmargin=*,labelindent=5cm]
    \item[Item 1] Some words.
    \item[Item 2] Other words
    \item[Item 3] Different words\\More words belonging to item 3
    \item[Item 10000] a new item
    \item[Item 100000000000] a new item
\end{description}
\end{document}

Change the labelindent= to your liking. This results in:

results

Note that a too small labelindent leads to the labels going into the margins and perhaps out of the page.

EDIT2: Perhaps a nicer approach, making the columnwidth for the labels definable (with linebreaks when possible). You can change the labelwidth= to your liking.

\documentclass[]{scrartcl}
\usepackage{enumitem}
\SetLabelAlign{parright}{\strut\smash{\parbox[t]{\labelwidth}{\raggedleft#1}}}
\begin{document}
Using \texttt{description}:
\begin{description}[align=right,leftmargin=*,labelindent=5cm]
    \item[Item 1] Some words.
    \item[Item 2] Other words
    \item[Item 3] Different words\\More words belonging to item 3
    \item[Item 10000] a new item
    \item[Item 100000000000] a new item
\end{description}

New approach using \texttt{parright}:
\begin{description}[align=parright,leftmargin=!,labelwidth=2.5cm]
    \item[Item 1] Some words.
    \item[Item 2] Other words
    \item[Item 3] Different words\\More words belonging to item 3
    \item[Item 10000] a new item
    \item[Item 100000000000] a new item\\a new row
\end{description}
\end{document}

results

2
  • The description labels are not right-aligned – try Item 10000.
    – Bernard
    Commented Mar 24, 2017 at 13:14
  • @Bernard to be honest I didn't fully understand what he wants. Also with the align=right if you have really long labels it'll lead to the long labels to be outside of the page. I'll edit my answer.
    – Skillmon
    Commented Mar 24, 2017 at 13:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .