Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the posts to the question of Timtico (here) several ways have been proposed to colour the As,Ts,Cs and Gs differently within a DNA sequence. What I want is also to be able to underline some nucleotides to emphasise them, e.g.: \dna{ATACAG$\underbar{AG}$CATA} but I didn't manage to do so. Does anyone have suggestions to this problem? Thank you very much!

share|improve this question
    
Do you want to underline a specific subsequence like AG? Not everyone here is a biologist. Please describe your question without many professional terms, and provide some examples/pictures to illustrate the question. –  Leo Liu May 22 '11 at 11:51
    
You might want to have a look at the texshade package (Typesetting nucleotide and peptide alignments) and maybe also textopo (for shaded membrane protein topology plots) by the same author. –  cgnieder Mar 22 '12 at 17:52
add comment

1 Answer

up vote 4 down vote accepted

I added a delimiter to the code from my answer at typesetting different characters with different colors in a DNA sequence

\documentclass{article}
\usepackage{listings,xcolor}
\lstdefinestyle{dna}{%
    literate={A}{\textcolor{green}{A}}{1}
        {B}{\textcolor{blue}{B}}{1}
        {C}{\textcolor{red}{C}}{1}
        {a}{\textcolor{green}{A}}{1}
        {b}{\textcolor{blue}{B}}{1}
        {c}{\textcolor{red}{C}}{1},
    basicstyle=\ttfamily,
    moredelim=[is][\underline]{_}{_}
}
\newcommand{\DNA}[1]{%
    \lstinline[style=dna]{#1}%
}
\begin{document}
\DNA{AA_CAAAD_A}
\end{document}

The result is
result of the above code

I think, this should work for you.

share|improve this answer
    
Wow, that was indeed what I was looking for. Thank you very much!! –  Ros May 22 '11 at 13:52
    
@Ros Your welcome :-D –  Tobi May 22 '11 at 14:03
    
One additional question: would it also be possible to write the literate shorter? (That would be handy when colouring protein sequences, for which multiple letters have to be the same colour). E.g. something like this: literate={A,B,C,D}{\textcolor{green}{\1}}{1}, {E,F,G,H}{\textcolor{blue}{\1}}{1} etc.. –  Ros May 22 '11 at 17:20
    
@Ros: I don’t believe that there is a way to do it with listings. Maybe the manual can give you more information. ps. Note that there’s no comma , between the literate definitions. –  Tobi May 22 '11 at 17:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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