I would like to draw picture like this:

enter image description here

(This picture is snipped from a figure in this research paper)

It is important that a and a* or tb and tb* or tr and tr* etc are vertically aligned (because they represent complementary strands of DNA and they should be vertically aligned in the figure for it to be meaningful.)

I tried something, like this:

$_{\xleftharpoondown[ta^*a^*tb^*b^*tr^*r^*tq^*]{}}^{\text{      }\xrightharpoonup{a\text{ }tb}\xrightharpoonup{b\text{ }tr}\xrightharpoonup{r\text{ }tq}}$

And it gives:

enter image description here

So few complaints about the above figure:

  1. There is too much gap between the left harpoons and the right harpoons. How to fix this?

  2. The most important thing - the labels a and a* etc HAVE to be aligned! How to do that?

Also BONUS (but not strictly necessary):

I would like to use such a figure inline (like an equation). Right now what I have can be used inline. I am not sure if a tikz figure can be used inline. So please demonstrate how to use this figure inline.

EDIT: This stackexchange answer shows how to insert tikz figure inline. So the bonus question is kind of taken care of, if tikz is used. Please someone help me draw this with tikz!

EDIT: How to add a gap in the middle? Like this:

enter image description here

Labels not shown in above image, but they will be there and have to be aligned. Using the solution in the answer I could create this:

enter image description here

In this the first arrow on the top is wrong. It should start under ta and end under a, so that a gap is exposed over tb*

EDIT: I could solve it! Here is the code:

ta\ar[below] & a  & \,   & b \ar[below] & tr   & r \ar[below] & tq                      \\
ta^* & a^*          & tb^* & b^*          & tr^* & r^*          & tq^* \ar[llllll, above]

And this results in:

enter image description here

  • 1
    Welcome to TeX.SE!
    – Mensch
    Mar 27 at 21:46
  • It's best if you post your solution using the "Your Answer" box below.
    – Teepeemm
    Mar 28 at 14:03

1 Answer 1


Let's start with something.

We're using a TikZ \matrix via TikZ-CD. The DNA style sets up some values that help us align things.

The text depth and text height key make sure that all nodes have the same height and depth which helps align the arrows below or above them.

Speaking of arrows, there are the keys below and above (not to be confused with /tikz/above and /tikz/below) that draw the harpoons above a number of nodes from right to left or below a number of nodes from left to right.

The below key uses r by default which means that without any settings further it will always underline the current and the next node to the right.

The llllll in the above arrow means that the arrow will end above the node six columns to the left.

The way, the above and below key are set up the below style should always be used from the end of a row and the left target should be specified. The above key is best used in the first cell of a row.

Add baseline = -axis_height to the DNA key to have the picture align how a matrix in math mode usually would.

It looks like pairs of nodes on the top line should be closer together, for a regular top row the DNA* style can be used with the argument even or odd which specifies where no column sep should be added.

For more irregular diagrams, you can use the no csep key that accepts a list of columns after which the column sep should be 0.


  no csep/.style={/utils/temp/.style={/tikz/column ##1/.append style={
    column sep=+0pt}},/utils/temp/.list={#1}},
    column sep={\the\arraycolsep}, row sep=+.3em, thick,
    cells={inner xsep=+.15em, outer xsep=+.2em,
           text depth=+0pt, text height=+.7\ht\strutbox}},
  DNA*/.style={DNA, /tikz/every #1 column/.append style={column sep=+0pt}},
    /tikz/arrows=-{Straight Barb[left]},
    to path={(\tikztostart.north east) -- (\tikztotarget.north west)}},
  below/.style={% implicitly one to the right
    r, /tikz/arrows=-{Straight Barb[left]},
    to path={(\tikztostart.south west) -- (\tikztotarget.south east)}}}
\begin{tikzcd}[DNA*=even, cells={nodes={help lines,draw,text=black}}]
    & a \ar[below] & tb   & b \ar[below] & tr   & r \ar[below] & tq                      \\
  t & a^*          & tb^* & b^*          & tr^* & r^*          & tq^* \ar[llllll, above]

\begin{tikzcd}[DNA, no csep={1,4,6}]
  ta \ar[below] & a   & tb   & b \ar[below] & tr   & r \ar[below] & tq                      \\
  t             & a^* & tb^* & b^*          & tr^* & r^*          & tq^* \ar[llllll, above]


enter image description here

  • Excellent! This is a macro and can be reused conveniently! Mar 28 at 10:24
  • But how would I add a gap in the middle? I think I don't understand how to use the odd and even correctly. In the above there is a "gap" above the first t. Now I want to keep the bottom arrow as it is (t a* tb* b* tr* r* tq*). But on top I want t* a aligned with t a* below. Then there is a gap above tb*. Then the two arrows b tr and r tq as before. How to do this? Mar 28 at 10:27
  • I couldn't insert a figure in the comments. So I have added one in the main question under "EDIT". Mar 28 at 10:29
  • Also the arrows on the top go "end-to-end". There is a gap between the arrow ahead and the tail of the next arrow. How to remove that gap or at least reduce that gap? Mar 28 at 10:38
  • I could solve all the above! I my adding the solution in the main question as I can't add multi-line code here. Mar 28 at 11:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .