4

I'm writing a lab report about gene sequencing, and I have to put a large sequence of nucleotides. I don't really intend to put it on a special box, just add it as if it were another paragraph only with the sequence. But when I compile is becomes a total disaster, LaTeX is unable to just break the sequence to next line, making a long single line text that overpasses the limit. I'm also using texttt in order to print it with monospaced font.

\texttt{
TAATAATCATATAGATTCCGTTCACCAAGGAA\textbf{ATG}TCTGGATCTCGCAAATTTTTTGTTGGGGGGAACTGGAAAATGAACGGAAGCAGAGATGACAACGATAAGTTACTTAAGTTACTCTCAGAAGCTCATTTTGATGATAACACGGAAGTTTTAATTGCTCCACCTTCAGTCTTTTTGCACGAAATTCGAAAAAGTTTGAAGAAAGAAATACACGTGGCCGCTCAAAATTGCTATAAAGTATCAAAGGGTGCATTCACCGGAGAAATCAGCCCAGCAATGATAAGAGATATTGGTTGTGATTGGGTCATACTTGGACATTCTGAGCGTAGAAACATTTTTGGTGAATCTGATGAACTTATTGCTGAAAAAGTTCAACATGCACTTGCTGAAGGTCTAAGCGTTATTGCATGTATTGGTGAAACATTATCAGAGCGTGAATCTAATAAAACAGAGGAAGTATGCGTTAGACAGTTAAAAGCTATTGCAAATAAGATTAAATCAGCTGATGAATGGAAACGAGTAGTCGTAGCATATGAACCAGTTTGGGCTATTGGAACAGGTAAAGTTGCTACACCACAACAAGCTCAAGAAGTTCATAATTTCCTTCGTAAATGGTTTAAAACGAATGCACCAAATGGAGTTGATGAAAAAATACGTATTATCTATGGTGGATCTGTAACTGCTGCCAATTGTAAAGAATTAGCTCAACAACATGATGTCGATGGATTTTTGGTTGGTGGAGCTTCATTAAAACCGGAATTCACTGAGATATGTAAAGCCAGACAACGT\textbf{TGA}ACGTTTTGTTGGTCTTCTTCTTCTTACGCTTCTAAATTTTGTCTCTTCTCATGTCAGTTACTTGCTTTTTTTGTCTTGTTTTTTTGTTTTGACAACCAAAGCATATTATAATTAGTAGTATCTTAATGTCTAATGTAAAAAAAAATATCACCACTAGTTCGAACTATTTAATTACTATCAGTCAAAAAAATAATATTTGTCAATTTAGTTCATTGTTTCATTTATCGTCCCTTCTATTTAAATTTCTTATGGCCTAAATATACCTTGAATTAATAAAAAAAAAAAA}

Last attempts resulted in Latex hyphenating gibberish, with textttt it just doesn't break the text at all. Also, I'm unable to make the text bold. Thanks for reading.

  • Welcome to TeX.SX! You should look at the seqsplit package. – egreg Aug 15 '15 at 20:52
4

The seqsplit package is exactly for this. In the example I use the Bera Mono font, because the default monospaced font doesn't have a boldface version.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{beramono}
\usepackage{seqsplit}

\begin{document}

\noindent\texttt{\seqsplit{%
  TAATAATCATATAGATTCCGTTCACCAAGGAA{\textbf{ATG}}TCTGGATCTCGCAAATTTTTTGTT%
  GGGGGGAACTGGAAAATGAACGGAAGCAGAGATGACAACGATAAGTTACTTAAGTTACTCTCAGAAGCTC%
  ATTTTGATGATAACACGGAAGTTTTAATTGCTCCACCTTCAGTCTTTTTGCACGAAATTCGAAAAAGTTT%
  GAAGAAAGAAATACACGTGGCCGCTCAAAATTGCTATAAAGTATCAAAGGGTGCATTCACCGGAGAAATC%
  AGCCCAGCAATGATAAGAGATATTGGTTGTGATTGGGTCATACTTGGACATTCTGAGCGTAGAAACATTT%
  TTGGTGAATCTGATGAACTTATTGCTGAAAAAGTTCAACATGCACTTGCTGAAGGTCTAAGCGTTATTGC%
  ATGTATTGGTGAAACATTATCAGAGCGTGAATCTAATAAAACAGAGGAAGTATGCGTTAGACAGTTAAAA%
  GCTATTGCAAATAAGATTAAATCAGCTGATGAATGGAAACGAGTAGTCGTAGCATATGAACCAGTTTGGG%
  CTATTGGAACAGGTAAAGTTGCTACACCACAACAAGCTCAAGAAGTTCATAATTTCCTTCGTAAATGGTT%
  TAAAACGAATGCACCAAATGGAGTTGATGAAAAAATACGTATTATCTATGGTGGATCTGTAACTGCTGCC%
  AATTGTAAAGAATTAGCTCAACAACATGATGTCGATGGATTTTTGGTTGGTGGAGCTTCATTAAAACCGG%
  AATTCACTGAGATATGTAAAGCCAGACAACGT\textbf{TGA}ACGTTTTGTTGGTCTTCTTCTTCTTA%
  CGCTTCTAAATTTTGTCTCTTCTCATGTCAGTTACTTGCTTTTTTTGTCTTGTTTTTTTGTTTTGACAAC%
  CAAAGCATATTATAATTAGTAGTATCTTAATGTCTAATGTAAAAAAAAATATCACCACTAGTTCGAACTA%
  TTTAATTACTATCAGTCAAAAAAATAATATTTGTCAATTTAGTTCATTGTTTCATTTATCGTCCCTTCTA%
  TTTAAATTTCTTATGGCCTAAATATACCTTGAATTAATAAAAAAAAAAAA}}

\end{document}

enter image description here

I would make a change in the definition of \seqsplit:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{beramono}
\usepackage{seqsplit}

\makeatletter
\renewcommand{\seqsplit}[2][\seqsplitdefaultfont]{%
  \begingroup
  #1% should be a font selection command
  \SQSPL@scan#2\SQSPL@end
  \endgroup
}
\makeatother
\newcommand{\seqsplitdefaultfont}{\ttfamily}% or whatever you prefer as default

\begin{document}

\noindent
\seqsplit{%
  TAATAATCATATAGATTCCGTTCACCAAGGAA{\textbf{ATG}}TCTGGATCTCGCAAATTTTTTGTT%
...

TTTAATTACTATCAGTCAAAAAAATAATATTTGTCAATTTAGTTCATTGTTTCATTTATCGTCCCTTCTA% TTTAAATTTCTTATGGCCTAAATATACCTTGAATTAATAAAAAAAAAAAA}

\end{document}

One can change the setup on the fly by typing, for instance,

\seqsplit[\ttfamily\bfseries]{...}

if in some case you want monospaced boldface for the whole sequence.

  • We had the same idea, but you were posting while I was finishing my example! I'll withdraw my post in a moment. – Bernard Aug 15 '15 at 21:04
  • @Bernard Maybe you can describe the solution with dnaseq – egreg Aug 15 '15 at 21:07
  • Having such theme for the first paper on LaTeX was a horrible idea. Hahahahaa. But thanks to your help I think it will look amazing. Thanks! – Bruno Yamada Aug 16 '15 at 14:31
4

The seqsplit package is done for that. Here is a little demo of the possibilities (which probably have nothing to do with what you really need). If you don't know it you also might take a look at the dnaseq package. I also give a demo of it

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[showframe]{geometry}%
\usepackage{xcolor}
\usepackage{seqsplit, dnaseq}
\usepackage[default]{sourcecodepro}
% inconsolata
\begin{document}

\vspace*{1cm}
\noindent\seqsplit{\ttfamily%\ttfamily
\bgroup\itshape\bfseries TAA\egroup TAATCATATAGATTCCGTTCACCAAGGAAATGTCTGGATCTCGC{\color{red}AAA\color{black}}TTTTTTGTTGGGGGGAACTGGAAAATGAACGGAAGCAGAGATGACAACGATAAGTTACTTAAGTTACTCTCAGAAGCTCATTTTGATGATAACACGGAAGTTTTAATTGCTCCACCTTCAGTCTTTTTGCACGAAATTCGAAAAAGTTTGAAGAAAGAAATACACGTGGCCGCTCAAAATTGCTATAAAGTATCAAAGGGTGCATTCACCGGAGAAATCAGCCCAGCAATGATAAGAGATATTGGTTGTGATTGGGTCATACTTGGACATTCTGAGCGTAGAAACATTTTTGGTGAATCTGATGAACTTATTGCTGAAAAAGTTCAACATGCACTTGCTGAAGGTCTAAGCGTTATTGCATGTATTGGTGAAACATTATCAGAGCGTGAATCTAATAAAACAGAGGAAGTATGCGTTAGACAGTTAAAAGCTATTGCAAATAAGATTAAATCAGCTGATGAATGGAAACGAGTAGTCGTAGCATATGAACCAGTTTGGGCTATTGGAACAGGTAAAGTTGCTACACCACAACAAGCTCAAGAAGTTCATAATTTCCTTCGTAAATGGTTTAAAACGAATGCACCAAATGGAGTTGATGAAAAAATACGTATTATCTATGGTGGATCTGTAACTGCTGCCAATTGTAAAGAATTAGCTCAACAACATGATGTCGATGGATTTTTGGTTGGTGGAGCTTCATTAAAACCGGAATTCACTGAGATATGTAAAGCCAGACAACGT\textbf{TGA}ACGTTTTGTTGGTCTTCTTCTTCTTACGCTTCTAAATTTTGTCTCTTCTCATGTCAGTTACTTGCTTTTTTTGTCTTGTTTTTTTGTTTTGACAACCAAAGCATATTATAATTAGTAGTATCTTAATGTCTAATGTAAAAAAAAATATCACCACTAGTTCGAACTATTTAATTACTATCAGTCAAAAAAATAATATTTGTCAATTTAGTTCATTGTTTCATTTATCGTCCCTTCTATTTAAATTTCTTATGGCCTAAATATACCTTGAATTAATAAAAAAAAAAAA}

\vspace*{1cm}
\DNA ! TAATCATATAGATTCCGTTCACCAAGGAAATGTCTGGATCTCGC'{red}AAA'{white}TTTTTTGTTGGGGGGAACTGGAAAATGAACGGAAGCAGAGATGACAACGATAAGTTACTTAAGTTACTCTCAGAAGCTCATTTTGATGATAACACGGAAGTTTTAATTGCTCCACCTTCAGTCTTTTTGCACGAAATTCGAAAAAGTTTGAAGAAAGAAATACACGTGGCCGCTCAAAATTGCTATAAAGTATCAAAGGGTGCATTCACCGGAGAAATCAGCCCAGCAATGATAAGAGATATTGGTTGTGATTGGGTCATACTTGGACATTCTGAGCGTAGAAACATTTTTGGTGAATCTGATGAACTTATTGCTGAAAAAGTTCAACATGCACTTGCTGAAGGTCTAAGCGTTATTGCATGTATTGGTGAAACATTATCAGAGCGTGAATCTAATAAAACAGAGGAAGTATGCGTTAGACAGTTAAAAGCTATTGCAAATAAGATTAAATCAGCTGATGAATGGAAACGAGTAGTCGTAGCATATGAACCAGTTTGGGCTATTGGAACAGGTAAAGTTGCTACACCACAACAAGCTCAAGAAGTTCATAATTTCCTTCGTAAATGGTTTAAAACGAATGCACCAAATGGAGTTGATGAAAAAATACGTATTATCTATGGTGGATCTGTAACTGCTGCCAATTGTAAAGAATTAGCTCAACAACATGATGTCGATGGATTTTTGGTTGGTGGAGCTTCATTAAAACCGGAATTCACTGAGATATGTAAAGCCAGACAACGTTGAACGTTTTGTTGGTCTTCTTCTTCTTACGCTTCTAAATTTTGTCTCTTCTCATGTCAGTTACTTGCTTTTTTTGTCTTGTTTTTTTGTTTTGACAACCAAAGCATATTATAATTAGTAGTATCTTAATGTCTAATGTAAAAAAAAATATCACCACTAGTTCGAACTATTTAATTACTATCAGTCAAAAAAATAATATTTGTCAATTTAGTTCATTGTTTCATTTATCGTCCCTTCTATTTAAATTTCTTATGGCCTAAATATACCTTGAATTAATAAAAAAAAAAAA
! 

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.