1

I would like to take two lines of column-aligned text (double-stranded DNA data) and add some boxes around some of the text, and additional labels. I normally use tikz for this kind of figure, but I am having difficulties retaining the column-aligned text in tikz.

      ATTGGNAGCAGAACCCCATGCGCTGGCGCGGCTACGACAGCTAACTTGAGA...
...AGATAACNNTCGTCTTGGGGTACGCGACCGCGCCGATGCTNTCGATTGAAC

I have tried using a Verbatim (fancyvrb) and verbatim environment inside a tikz node, but this has compilation errors like this question.

\documentclass{beamer}

\usepackage{tikz}
\usepackage{fancyvrb}

\begin{document}

\begin{frame}[fragile]
\frametitle{Duplicates}
\begin{tikzpicture}
    \node[align=left]{
        \begin{Verbatim}
      ATTGGNAGCAGAACCCCATGCGCTGGCGCGGCTACGACAGCTAACTTGAGA...
...AGATAACNNTCGTCTTGGGGTACGCGACCGCGCCGATGCTNTCGATTGAAC
        \end{Verbatim}
    };
\end{tikzpicture}
\end{frame}

\end{document}

! LaTeX Error: Something's wrong--perhaps a missing \item.
l.4 \begin{Verbatim}

The question above is marked as a duplicate of a question whose answer indicates to use \Verb, which is not appropriate for my long strings.

I have also tried to use \texttt within a tikz node, but this does not align correctly.

\node[align=left]{
\texttt{      ATTGGNAGCAGAACCCCATGCGCTGGCGCGGCTACGACAGCTAACTTGAGA...}\\
\texttt{...AGATAACNNTCGTCTTGGGGTACGCGACCGCGCCGATGCTNTCGATTGAAC}
};

I have also considered using a tikz matrix, but this seems overly complicated with one node per letter.

Is there a relatively simple way of achieving the aligned text with drawing features?

2

I can't help you with the tikz overlays, but getting verbatim into the tikz node can be done with verbatimbox:

\documentclass{beamer}
\usepackage{tikz}
\usepackage{verbatimbox}
\begin{document}
\begin{frame}[fragile]
\frametitle{Duplicates}
\begin{verbbox}[\small]
      ATTGGNAGCAGAACCCCATGCGCTGGCGCGGCTACGACAGCTAACTTGAGA...
...AGATAACNNTCGTCTTGGGGTACGCGACCGCGCCGATGCTNTCGATTGAAC
\end{verbbox}
\begin{tikzpicture}
    \node[align=left]{\theverbbox};
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

Perhaps a less efficient way to add bells and whistles, but one which I do know is a \stackinset:

\documentclass{beamer}
\usepackage{tikz}
\usepackage{verbatimbox,stackengine,xcolor}
\begin{document}
\begin{frame}[fragile]
\frametitle{Duplicates}
\begin{verbbox}[\small]
      ATTGGNAGCAGAACCCCATGCGCTGGCGCGGCTACGACAGCTAACTTGAGA...
...AGATAACNNTCGTCTTGGGGTACGCGACCGCGCCGATGCTNTCGATTGAAC
\end{verbbox}
\stackinset{l}{100pt}{c}{}{\textcolor{red}{\framebox(68,22){}}}{\theverbbox}
\end{frame}
\end{document}

enter image description here

0

You also can put your text in a parbox and use one of the \seqsplit or \DNA commands, from the seqsplit and dnaseq packages:

\documentclass{beamer}

\usepackage{tikz}
\usepackage{fancyvrb}
\usepackage{dnaseq, seqsplit}

\begin{document}

\begin{frame}[fragile]
\frametitle{Duplicates}
\begin{tikzpicture}
 \node[align=left
 ]{\parbox{\linewidth}
 {\ttfamily\seqsplit{ATTGGNAGCAGAACCCCATGCGCTGGCGCGGCTACGACAGCTAACTTGAGA...
...AGATAACNNTCGTCTTGGGGTACGCGACCGCGCCGATGCTNTCGATTGAAC}

\DNA! ATTGGNAGCAGAACCCCATGCGCTGGCGCGGCTACGACAGCTAACTTGAGA...
...AGATAACNNTCGTCTTGGGGTACGCGACCGCGCCGATGCTNTCGATTGAAC! }
};
\end{tikzpicture}
\end{frame}

\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.