I am quite new in LaTeX and at the moment I am looking for an opportunity to describe strings (or URLs) like this:


Do you know a package I could use for something like this?

Thank you for your help!


A solution using TikZ just for fun:

    \draw (0,0) node[anchor=base] {$\overbrace{\texttt{jdbc}}$} node[above=2.5ex] {\textsf{\scriptsize Protocol}};
    \node[anchor=base] (a) at (0.5,0) {\texttt{:}};
    \node[anchor=base] (post) at (1.4,0) {$\overbrace{\texttt{postgres}}$};
    \node[anchor=base] (name) at (1.4,1) {\textsf{\scriptsize Product/Vendor Name}};
    \draw[->] (name)--(post);
    \node[anchor=base] (b) at (2.3,0) {\texttt{:}};
    \draw (4.3,0) node[anchor = base] {$\overbrace{\texttt{//localhost:5432/zoo}}$} node[above=2.5ex] {\textsf{\scriptsize Database Specific Connection Details}};
    \node[rectangle, draw=none] (rect) at (0.5,-1) {\textsf{\scriptsize Colon Separators}};
    \draw[->] (a)--(rect);
    \draw[->] (b) to[in=0,out=-90] (rect);

enter image description here

I said just for fun because this is not the optimal way. If the text is not


then you have to change (nearly) all the coordinates in, for example, at (1.4,0).

I'm sorry for not providing you the optimal way. As I rarely use something like this, I am a bit unfamiliar. However, the code provided above is basic TikZ that doesn't really require much effort to make. So I show you that code.


Another possibility is to use tikzmark do make the different elements of your text different nodes, and to annotate them with an overlay tikzpicture. That way you do not have to re-adjust dimensions if the text changes. (You will, however, have to add vertical space before and after the line since an overlay picture does not add space.

\begin{tikzpicture}[overlay,remember picture,overbrace/.style args={#1 with #2}{%
thick,decorate,decoration={brace,raise=1pt},insert path={
(#1.north west) -- (#1.north east)
\draw[overbrace=jdbc with Protocol];
\draw[overbrace=localhost with Database Specific\\ Connection Details];
\draw[thick,decorate,decoration={brace,raise=1pt}] (postgres.north west) --
(postgres.north east) coordinate[midway,above=2pt] (aux);
\draw[latex-] (aux) -- ++(0,12mm)
node[above,font=\sffamily,align=center]{Database Specific\\ Connection Details};
\draw[-latex] (c1) -- ++ (0,-1cm) node[below,font=\sffamily] (CS) {Colon separators};
\draw[-latex] (c2) to[out=-90,in=0] (CS);

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.