2

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!

Argalatyr
  • 4,639
  • 3
  • 36
  • 62

5 Answers5

7

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
  • 5,504
  • 1
  • 25
  • 32
6

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
  • 8,636
  • 1
  • 20
  • 21
3

I haven't tried it, but it looks like the newicktree package may be of some interest to you. The article PHY·FI: fast and easy online creation and manipulation of phylogeny color figures and the associated web-based tool also seem like they would be helpful.


EDIT: I found a way to more or less accomplish what you want by using a package in a way that it almost certainly was not intended. Here is the LaTeX code:

\documentclass{article}
\usepackage{url}
\begin{document}
\url{((((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}

Here is the result: IMAGE http://img230.imageshack.us/img230/4705/newick.png

las3rjock
  • 8,612
  • 1
  • 31
  • 33
1

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
  • 62,540
  • 32
  • 99
  • 117
0

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
  • 50,694
  • 11
  • 78
  • 122