1

I am new to LaTeX and I am trying to write my dissertation using LaTeX. Recently, I was working on this tutorial with Lipsum to create random text. Upon compiling, I see that some of these lines are overhanging. Is there a simple way to avoid this?

\documentclass[12pt,letterpaper,oneside]{article}
\usepackage[margin=1in]{geometry}
\usepackage{fontspec} % Allows to choose any system font with XeLaTeX
\setmainfont{Palatino} % Sets main font to Arial, Book Antiqua, Helvetica Neue
\usepackage{lipsum} % To generate test text, use \lipsum[#numoflines#] in body
\usepackage{tocloft} % Package for Table of Contents, Lists of Figures and Tables
\renewcommand{\contentsname}{Table of Contents} % Changes the 'Contents' to 'Table of Contents'
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} % Sets the dots in the section leader in Table of Contents; See PDF
\renewcommand{\cftdot}{.} % Renews the Dots in the TOC to user chosen symbols
\renewcommand{\cfttoctitlefont}{\Huge} % Renews the TOC title font. Can set the size or font type

\title{Interesting Tutorial}
\author{John Doe}
\date{\today}

\begin{document}

\maketitle
\thispagestyle{empty}
\setcounter{page}{1}
\pagenumbering{roman}
\newpage
\tableofcontents

\clearpage
\pagenumbering{arabic}
\section{TeX Tutorial 1}
\subsection{Your First Document}
\lipsum[10]
\section{TeX Tutorial 2}
\subsection{Make Title Command}
\lipsum[11-20]

\end{document}

enter image description here enter image description here

1

The lines are overhanging into the right-hand margin because there are no hyphenation patterns for some of the words to properly break them. You can try adding \sloppy at the beginning of the document; this loosens the restrictions on stretch for lines that have protruding text, like in your case. Compare the below with/without \sloppy:

\documentclass{article}

\usepackage{lipsum}

\begin{document}

\sloppy\lipsum[1-50]

\end{document}

Alternatively, use a different text generator, like kantlipsum or blindtext.

\kant[1-50]

\blindtext
  • wow. Thanks a ton. The \sloppy works like a charm. However, the spacing between words is loose (as you have mentioned). \kant still suffers from the original problem but the random text is more english (so that is good to know). – Shah Saud Alam Dec 13 '18 at 2:41
  • @ShahSaudAlam: Sure... but you're not submitting a dissertation with \lipsum text, surely. You're just wanting to generate a template that showcases a specific layout. – Werner Dec 13 '18 at 3:03
  • oh yeah, definitely. I am just trying to create a template that can accept chapter files (.tex) later and take care of all of the formatting for me. – Shah Saud Alam Dec 13 '18 at 3:28

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.