14

I have a LaTeX document that is automatically generated and then inserted as part of my own larger document with \input. This other document has a description environment for examples, one item for each. The problem is that some of them are very long and run out of the paper margins. Here's an example,

\begin{description}

\item[{\texttt{bp\_genbank\_ref\_extractor --transcripts=accession '"homo sapiens"[organism] AND H2B'}}] \mbox{}

Search Entrez gene with the query \texttt{'"homo sapiens"[organism] AND H2B'}, and
save their transcripts sequences. Note that default value of \textbf{--limit} may only extract
some of the hits.


\item[{\texttt{bp\_genbank\_ref\_extractor --transcripts=accession --proteins=accession --format=fasta '"homo sapiens"[organism] AND H2B' '"homo sapiens"[organism] AND MCPH1'}}] \mbox{}

Is there a way to force them to wrap around without changing the file? Something I can do before calling \input? The text there will run for several pages and is a section of the appendixes (I'm using the memoir class).

This document is generated automatically from the POD documentation of a perl script using pod2latex.

3 Answers 3

12

The enumitem package has an option to description: style=unboxed and thus the contents of \item[...] is then wrapped. One might also get away by redefining \descriptionlabel, though I don't think the broken line will be indented (I tend to like having them stand out, so when I use there very long titles I have the text start on the next line after the title.

2
  • that worked fine. The package does not accept the option with \usepackage. Instead, I had to use \setlist[description]{style=unboxed}. I set it right before the call to \input to avoid changing the rest of the document. Still, it may affect whatever comes after. Do you know how to make this options apply only there?
    – carandraug
    Feb 1, 2013 at 13:19
  • I have found how to do it. It's in the manual. Basically, just set the style back to standard after. The following sequence does what I wanted \setlist[description]{style=unboxed}, \input{documentation}, \setlist[description]{style=standard}.
    – carandraug
    Feb 1, 2013 at 13:47
5

The following works for memoir as well as the standard document classes (article, book and report). It avoids using the \item label (passed as an optional argument) of description, and rather unskips the space inserted after it was usually set. The reasoning here is that, by default, the \item label is set in a box, which doesn't break across the line boundary.

enter image description here

\documentclass{memoir}
\begin{document}
\begin{description}
  \item[{\texttt{bp\_genbank\_ref\_extractor --transcripts=accession '"homo sapiens"[organism] AND H2B'}}] \par
    Search Entrez gene with the query \texttt{'"homo sapiens"[organism] AND H2B'}, and
    save their transcripts sequences. Note that default value of \textbf{--limit} may only extract
    some of the hits.

  \item \hspace*{-\labelsep}%
    \textbf{\texttt{bp\_genbank\_ref\_extractor --transcripts=accession '"homo sapiens"[organism] AND H2B'}} \par
    Search Entrez gene with the query \texttt{'"homo sapiens"[organism] AND H2B'}, and
    save their transcripts sequences. Note that default value of \textbf{--limit} may only extract
    some of the hits.

  \item {\hspace*{-\labelsep}\raggedright
    \textbf{\texttt{bp\_genbank\_ref\_extractor --transcripts=accession '"homo sapiens"\hspace{0pt}[organism] AND H2B'}} \par}
    Search Entrez gene with the query \texttt{'"homo sapiens"[organism] AND H2B'}, and
    save their transcripts sequences. Note that default value of \textbf{--limit} may only extract
    some of the hits.
  \end{description}
\end{document}

I've used \raggedright and possibly some \hspace{0pt} here/there to allow breaking it a proper location; it seems like you're dealing with some constructs that require some help in that regard.

Note that lists are usually document class dependent. So more work/investigation is required for document classes other than the ones listed above.

1
  • thanks for the tip but I cannot change the input file where the actual description environment is. I can only add code on my own LaTeX document before, or after the call to \input.
    – carandraug
    Feb 1, 2013 at 13:05
4

If you have the possibility to change the input file, I would suggest not to use a list but a sectioning command. This will also prevent a page break between the "title" and the text of the entry. Here an example with the \minisec command of the KOMA-classes:

\documentclass[]{scrartcl}
\usepackage[T1]{fontenc}
\begin{document}

\setkomafont{minisec}{\ttfamily}
\minisec{bp\_genbank\_ref\_extractor --transcripts=accession '"homo sapiens"[organism] AND H2B'}
Search Entrez gene with the query \texttt{'"homo sapiens"[organism] AND H2B'}, and
save their transcripts sequences. Note that default value of \textbf{--limit} may only extract
some of the hits.


\minisec{bp\_genbank\_ref\_extractor --transcripts=accession --proteins=accession --format=fasta '"homo sapiens"[organism] AND H2B' '"homo sapiens"[organism] AND MCPH1'}
Search Entrez gene with the query \texttt{'"homo sapiens"[organism] AND H2B'}, and
save their transcripts sequences. Note that default value of \textbf{--limit} may only extract
some of the hits.


\end{document}

You must log in to answer this question.

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