views:

1517

answers:

5

Hello,

I need to insert text like this in my Latex document:

((((tetrameristaceae,pellicieraceae),marcgraviaceae),balsaminaceae),(fouquieriaceae,polemoniaceae,sladeniaceae,(ternstroemia,adinandra)pentaphylacaceae,(schima,gordonia)theaceae,(lissocarpa,diospyros)ebenaceae,symplocaceae,(maesaceae,(theophrastaceae,(primulaceae,(myrsine,ardisia)myrsinaceae))),(diapensiaceae,(parastyrax,styrax)styracaceae),sapotaceae,(barringtonia,gustavia)lecythidaceae,(((ericaceae,cyrillaceae),(purdiaea,clethra)clethraceae),(sarraceniaceae,((actinidia,saurauia)actinidiaceae,roridulaceae)))))ericales;

Latex writes the all text in one line, going way off in the right margin. I cannot use \linebreak by hand, this just gives a poor result when the text is longer, and it would be a lot of work given all the similar text to include.

Any idea?

Thanks!

+7  A: 

Your question lacks the definition of the desired outcome, so I'll just try to guess.

Simplest idea: just add spaces after each comma.

ADEpt
And as a bonus, it looks better too.
ShreevatsaR
+4  A: 

You could add hyphenation hints in the text: if you put \- in a word (for example non\-breaking) LaTeX will break only at those position but will break at those positions if necessary. You'll get a hyphen at the breaking position though. Another possible option might be using the hyphenat package and defining the comma as your hyphenation character. As I never used that package myself I might be wrong here though.

bluebrother
+2  A: 
las3rjock
+1  A: 

Here's a quick solution that gets part of the way there (as far as I can tell). It doesn't require any changes to the markup, but allows you to insert extra spaces if you like automatically.

\documentclass{article}
\begin{document}
\newcommand\comma{,}
\newcommand\openbrace{(}
\newcommand\closebrace{)}
\begingroup
\catcode`\,=\active
\catcode`\(=\active
\catcode`\)=\active
\gdef\weird{%
  \begingroup
  \catcode`\,=\active
  \catcode`\(=\active
  \catcode`\)=\active
  \def,{\comma\allowbreak}%
  \def({\openbrace\allowbreak}%
  \def){\closebrace\allowbreak}%
  \processweird
}
\endgroup
\newcommand\processweird[1]{#1\endgroup}
\weird{((((tetrameristaceae,pellicieraceae),marcgraviaceae),balsaminaceae),(fouquieriaceae,polemoniaceae,sladeniaceae,(ternstroemia,adinandra)pentaphylacaceae,(schima,gordonia)theaceae,(lissocarpa,diospyros)ebenaceae,symplocaceae,(maesaceae,(theophrastaceae,(primulaceae,(myrsine,ardisia)myrsinaceae))),(diapensiaceae,(parastyrax,styrax)styracaceae),sapotaceae,(barringtonia,gustavia)lecythidaceae,(((ericaceae,cyrillaceae),(purdiaea,clethra)clethraceae),(sarraceniaceae,((actinidia,saurauia)actinidiaceae,roridulaceae)))))ericales;}
\end{document}
Will Robertson
A: 

As far as I know, you can put whitespace between nodes and have the usual linebreaks. You can also introduce optional hyphenations (with a hyphen) by inserting \- in the words.

If you (or whoever has to approve your work) insists on arbitrary breaks, perhaps you can use the seqsplit package.

Svante