# How to draw a line crossing two strings?

I want to type two strings in mono-spaced font and I want a line that make a subdivision of these two strings without altering how they are without this line.

I know that it is a bit unclear but this is the best that I've done so farbut there are two things that I don't know how to do.

1. I want that the distance between the 2nd and the 4th lines (i.e the two strings) to be like the normal line spacing (i.e. the 1st, the 3rd and the 5th lines should have no height)
2. In order to maintain the distance between characters constant even in case of a line between them I forced a space between letters. The goal should be to have no space between characters even if they have the line between them.

\documentclass[preview]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pmboxdraw}
\usepackage{newunicodechar}
\newunicodechar{└}{\textSFii}
\newunicodechar{─}{\textSFx}
\newunicodechar{┐}{\textSFiii}
\begin{document}
\texttt{~~~~~~~│}\par
\texttt{5'\ldots G │ A N T C\ldots 3'}\par
\texttt{~~~~~~~└─────┐  }\par
\texttt{3'\ldots C T N A │ G\ldots 5'}\par
\texttt{~~~~~~~~~~~~~│}
\end{document}


The solution could be with TikZ. The only requirement is that it should works with PDFLaTeX.

Edit 1:

This is the code after I followed the answer from Percusse but there is a problem with \ldots.

    \documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\foreach \x[count=\xi] in {5',\ldots,G,A,N,T,C,\ldots,3'}{\node[inner sep=0] (u-\xi) at (0.3*\xi,0.5){\x};}
\foreach \x[count=\xi] in {3',\ldots,C,T,N,A,G,\ldots,5'}{\node[inner sep=0] (d-\xi) at (0.3*\xi,0){\x};}
\draw ($(u-3.north)!0.5!(u-4.north)$)|-($(u-5)!0.5!(d-5)$)-|($(d-6.south)!0.5!(d-7.south)$);
\end{tikzpicture}
\end{document}


Edit 2: Even if I still have a problem with \ldots, I marked the answer by Percusse the accepted one. The one proposed by marmot is also good but require a double compilation for obvious reasons.

You can tweak further

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\foreach \x[count=\xi] in {G,A,N,T}{\node[inner sep=0] (u-\xi) at (0.3*\xi,0.5){\x};}
\foreach \x[count=\xi] in {C,T,N,A,G}{\node[inner sep=0] (d-\xi) at (0.3*\xi,0){\x};}
\draw ($(u-1.north)!0.5!(u-2.north)$)|-($(u-3)!0.5!(d-3)$)-|($(d-4.south)!0.5!(d-5.south)$);
\end{tikzpicture}
\end{document}


• Thanks, it's almost want I want. I tried to extend your example to my needs but I have troubles with \ldots. I edited the question to show it. – gvgramazio Apr 21 '18 at 17:03
• @giusva put other nodes with \ldots left of (u-1) and (d-5) – percusse Apr 21 '18 at 17:05
• if you mean that I can modify the \foreach loop I did but the \ldots are displayed as central dots. – gvgramazio Apr 21 '18 at 17:16
• However if I put them outside of the loop they are displayed correctly. Why it happens? – gvgramazio Apr 21 '18 at 17:18

If you just want to draw a line between the characters without moving them, consider using overlay.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\tikznode}[2]{\tikz[remember picture,baseline=(#1.base)]{\node(#1)[inner sep=0pt]{#2};}}
\begin{document}
\noindent
\foreach \X[count=\Y] in {G,A,N,T}
{\tikznode{upper-\Y}{\X}}\\
\foreach \X[count=\Y] in {C,T,N,A,G}
{\tikznode{lower-\Y}{\X}}
\begin{tikzpicture}[overlay,remember picture]
\coordinate (middle) at ($(upper-1.south)!0.5!(lower-1.north)$);
\draw (upper-1.north east) -- (upper-1.north east |- middle)
-- (lower-4.south west |- middle)
-- (lower-4.south west);
\end{tikzpicture}
\end{document}