2

I am using the description environment for a set of definitions. A label that I have is too long to fit in the left margin of the page. I do not know how to force a line break in the item label - nor do I want to. Is there a way to get the description environment to detect when a label is too long and have it break such that that the item label is still right aligned?

Note: My question is different than the question mentioned in the comments because I specifically want the label in the margin, not inside the main body of the page.

\documentclass[12pt, letterpaper, oneside, draft]{memoir}
\usepackage{enumitem}

% itemize environment configuration
\setlist[itemize]{noitemsep, topsep=0pt}

\begin{document}
\begin{description}[align=right]
\item[Rate of Reinforcement] Text that doesn't matter. The label is the same label that I need to use.
\end{description}

\end{document}

Edit (followup): I implemented the solution from the accepted answer, however now I get this. Any idea on why there are now question marks leading the label? weird question marks

K. Shores
  • 265
  • 1
    It is a duplicate but that solution does not work with this. Try it out. You will see that the text is no longer in the margin and is bunched together. – K. Shores Jun 21 '17 at 02:44

3 Answers3

3

I guess you mean something like this. I just put 3cm as label width but you could also retrieve the exact width of the margin from memoir.

\documentclass[12pt, letterpaper, oneside, draft]{memoir}
\usepackage{enumitem}
\usepackage{blindtext}

\SetLabelAlign{parright}{\smash{\parbox[t]{\labelwidth}{\raggedleft#1}}}

\begin{document}

\blindtext

\begin{description}[style=multiline,leftmargin=0pt,labelwidth=3cm,align=parright]
\item[Rate of Reinforcement] Text that doesn't matter. The label is
  the same label that I need to use. Make the line a little longer to
  show that it breaks nicely.
\item[Rate of Reinforcement] Text that doesn't matter. The label is
  the same label that I need to use. Make the line a little longer to
  show that it breaks nicely.
\item[Rate of Reinforcement] Short line to see it fail!
\item[Rate of Reinforcement] Text that doesn't matter. The label is
  the same label that I need to use. Make the line a little longer to
  show that it breaks nicely.
\end{description}

\blindtext

\end{document}

enter image description here

Henri Menke
  • 109,596
  • Thank you. I am now getting question marks before my item labels, but they are in the right spot. Do you know why this could happen with the information I have already given or do you think it is something more specific with my document (in which case I won't ask any more questions about these question marks on here)? – K. Shores Jun 22 '17 at 03:08
  • @K.Shores You can answer this yourself. Do question marks show up in my answer? No, thus it must be your document. – Henri Menke Jun 22 '17 at 03:10
1

Try the following. You can play with values for leftmargin and labelindent (give it a negative value to move it into the margin).

\documentclass[12pt, letterpaper, oneside, draft]{memoir}
\usepackage{enumitem}

% itemize environment configuration
\setlist[itemize]{noitemsep, topsep=0pt}
\SetLabelAlign{parright}{\parbox[t]{\labelwidth}{\raggedleft#1}}


\begin{document}
\lipsum[1]
\begin{description}[style=multiline,leftmargin=1in,labelindent=-\leftmargin,align=parright]

\item[Rate of Reinforcement] Text that doesn't matter. The label is the same label that I need to use.
\item[Reinforcement] Text that doesn't matter. The label is the same label that I need to use.

\end{description}

\end{document}

output of code

Alan Munn
  • 218,180
1

You could replace \item, but you would have to do it over again for every description environment.

\documentclass{article}
\usepackage{enumitem}
\usepackage{ifoddpage}
\usepackage{showframe}

\setlist[itemize]{noitemsep, topsep=0pt}

\newcommand{\biglabel}[1]% #1 = label for \item
{\checkoddpage
  \bgroup% use local registers
  \ifoddpageoroneside% compute margin size
    \dimen0=\oddsidemargin
  \else
    \dimen0=\evensidemargin
  \fi
  \advance\dimen0 by 1in
  \settowidth{\dimen1}{\textbf{#1}}% compute label size
  \ifdim\dimen1>\dimen0
    \smash{\parbox[t]{\dimen0}{\raggedleft #1}}%
  \else
    #1
  \fi
\egroup}

\begin{document}
\begin{description}[align=right]
\item[\biglabel{Another Rate of Reinforcement}] Text that doesn't matter. The label is the same label that I need to use.
The question is what happens to the second line,
\end{description}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120