# Geometry margin causing tasks alignment issue

For some reason, if one sets a margin using the geometry package, this causes an alignment problem with the tasks package:

MWE:

\documentclass[12pt]{article}

\geometry{a4paper, margin=2cm}

\begin{document}\raggedright

\begin{enumerate}
\item Prove the following:
\begin{problems}(4)
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\end{problems}
\end{enumerate}

\end{document}


Interestingly, at certain values, e.g. margin = 1in, there is no problem. But at other values, such as margin = 0.5cm, which is smaller than a 1in margin, there are problems. This eliminates a minimum width issue. What is the solution to this?

• \raggedright does some magic internally, and is being responsible for the issue you see. Sep 17, 2017 at 6:42
• Is there a way to fix this but maintain raggedright? Sep 17, 2017 at 6:53

One should reset \@rightskip. Imho the tasks package should do it. So make a bug report:

\documentclass[12pt]{article}

\usepackage{amsmath,geometry}

\geometry{a4paper, margin=2cm}

\begin{document}\raggedright

\begin{enumerate}
\item Prove the following:
\begingroup
\makeatletter
\@rightskip=0pt
\begin{problems}(4)
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\end{problems}
\endgroup
\end{enumerate}

\end{document}

• You could use \AtBeginEnvironment{problems}{\setlength\@rightskip{0pt}} (requires etoolbox). Sep 22, 2017 at 9:41
• I added something to my tracker so I don't forget: github.com/cgnieder/tasks/issues/10 Sep 22, 2017 at 13:14
• Would there be any way to wrap this in an environment? E.g. (with xParse) \NewDocumentEnvironment{dummyEnvironment}{} {\begingroup \makeatletter \@rightskip=0pt \problems(2)} {\endgroup\endproblems} Doesn't work. Sep 25, 2017 at 5:55

Could a solution with \RaggedRight from ragged2e package be acceptable?

EDIT: Ulrike has already given the perfect answer but I'd like to add TeXnician's suggestion (\usepackage[none]{hyphenat}) to my original answer:

\documentclass[12pt]{article}

\usepackage[none]{hyphenat}

\geometry{a4paper, margin=2cm}
\usepackage{ragged2e}

\usepackage{mwe}

\begin{document}\RaggedRight
\blindtext
\begin{enumerate}
\item \blindtext Prove the following:
\begin{problems}(4)
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\end{problems}
\end{enumerate}
\blindtext
\end{document}


Moreover, as egreg suggested to me in chat, another simple solution could be justifying only the problems environment:

\documentclass[12pt]{article}

\geometry{a4paper, margin=2cm}
\usepackage{ragged2e}

\usepackage{mwe}

\begin{document}\raggedright
\blindtext
\begin{enumerate}
\item \blindtext Prove the following:
\begin{justify}
\begin{problems}(4)
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\item $x$
\end{problems}
\end{justify}
\end{enumerate}
\blindtext
\end{document}


The output is more or less the same as before:

• Problem is the hyphenation that occurs with that. If there is a way around that, we might have a solution! Sep 22, 2017 at 8:11
• Hi! Please leave it up, someone else might know how to fix the hyphenation problem. Sep 22, 2017 at 8:16
• But that is pretty close anyway, thanks very much! Sep 22, 2017 at 8:17
• For hyphenation tex.stackexchange.com/questions/5036/… could help. Sep 22, 2017 at 8:56
• @Pravin See the link TeXnician posted Sep 22, 2017 at 8:59