6

I have a problem with description environment. The text exceeds the width of the page

\documentclass[a4paper,twoside,10pt]{report}
\usepackage[francais]{babel} 
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage{lmodern} 
\usepackage{geometry}
\geometry{hmargin=2.5cm,vmargin=2.5cm}
\begin{document}
\pagestyle{empty} 
\chapter{Some small hints}\label{hints}
\section{German Umlauts and other Language Specific Characters}\label{umlauts}
You can type german umlauts like 'ä', 'ö', or 'ü' directly in this file.
\begin{description}
\item [small item:] Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\item [Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse consequat   accumsan sodales. Duis pulvinar sagittis porta. Mauris malesuada vehicula turpis,] sed ornare ante. In pulvinar ligula a leo lacinia, vel laoreet tortor auctor. Nullam in tinc] Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{description}
\end{document}

this is the output :enter image description here

Is there a solution to ensure that the text goes to a new line automatically ? thanks

3

You can do that withsameline option from the enumitem package. Incidentally, I changed the input enncoding to utf8, as it is more portable to another platform:

\documentclass[a4paper,twoside,10pt]{report}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{geometry}
\geometry{margin=2.5cm, showframe, nomarginpar}
\usepackage{enumitem}
\AtBeginDocument{\def\chaptername{Le Chapter}}

enter image description here

\begin{document}
\pagestyle{empty}
\chapter{Some small hints}\label{hints}
\section{German Umlauts and other Language Specific Characters}\label{umlauts}
You can type german umlauts like 'ä', 'ö', or 'ü' directly in this file.

\begin{description}[style =sameline]
\item [small item:] Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\item [Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse consequat accumsan sodales. Duis pulvinar sagittis porta. Mauris malesuada vehicula turpis,] sed ornare ante. In pulvinar ligula a leo lacinia, vel laoreet tortor auctor. Nullam in tinc]
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{description}
\end{document} 
3

Loading the enumitem gives you various style options for description. For example unboxed allows multiline labels:

Sample output

\documentclass[a4paper,twoside,10pt]{report}

\usepackage[francais]{babel} 
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern} 

\usepackage{enumitem}

\begin{document}

\begin{description}[style=unboxed]
\item [small item:] Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\item [Lorem ipsum dolor sit amet, consectetur adipiscing
  elit. Suspendisse consequat accumsan sodales. Duis pulvinar sagittis
  porta. Mauris malesuada vehicula turpis,] sed ornare ante. In
  pulvinar ligula a leo lacinia, vel laoreet tortor auctor. Nullam in
  tinc] Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{description}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.