# How to make a little graphic like in following example?

I actually searched the whole forum for an example but I cant figure out how to create such a graphic..

Is there even a way to create such things?

• Do you need it as an image? And what about the font? Could it be the standard for the? In math mode something similar could be obtained quite easyly. Let me know – phollox Jul 20 '18 at 22:59

There are probably several ways of doing it, but searching for such things can be tricky, in part because many questions are just like yours: an image, and the question "how do I do this?" And of course, there could well be that no one has asked how to make exactly such a diagram.

That said: Quick ugly hack before I turn in for the night. The numbers in the for-loop (0.12, 0.63 etc) correspond to the fractional horizontal distance between the lower left and lower right corner of the node with the URL, some fine tuning of those might be needed.

\documentclass[border=5mm]{standalone}
\usepackage{url}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}

\foreach [remember=\xb as \xa (initially 0)] \xb/\txt in {
0.12/Schema,
0.63/Authority,
0.79/Path,
0.91/Query,
1/Fragment}
{
\draw ($(foo.south west)!\xa!(foo.south east)$) |- coordinate [pos=0.75] (m)
($(foo.south west)!\xb!(foo.south east) + (-1pt,-5pt)$) --
($(foo.south west)!\xb!(foo.south east) + (-1pt,0)$);

\draw (m) -- ++(0,-5pt) node[below, font=\scriptsize\sffamily] {\txt};
}

\end{tikzpicture}
\end{document}


Here is an alternative to Torbjørn's nice answer which is based on Torbjørn's very useful command \tikznode. The advantage is that it you can control the positions of the vertical bars more easily because they are determined by the nodes, but the downside is that it does not (yet?) work with \url. (EDIT: shortened the code, following the suggestion by (guess who ;-) Torbjørn T. The shorter legs at the beginning and end are on purpose, however, if you don't like them, replace \strut by \vphantom{x}, say.)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\newcommand{\tikznode}[2]{\tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {#2};}
\begin{document}
\begin{tikzpicture}[overlay,remember picture,font=\sffamily]
\coordinate[below=4pt of 0.south] (B);
\foreach [count=\X from 0, count=\Z] \Y in {Schema,Authority,Path,Query,Fragment}
{\draw ([xshift=-1pt]\Z.south) -- ([xshift=-1pt]\Z.south |-B) -| ([xshift=1pt]\X.south)
coordinate[pos=0.25](M-\X);
\draw (M-\X) -- ++(0,-3pt) node[below]{\Y};}
\end{tikzpicture}
\end{document}


• Suggestion for minor (possible) improvement: \foreach [count=\X from 0, count=\Z] \Y in {Schema,Authority,Path,Query,Fragment}. Just noticed by the way that the first and last "leg" of the brackets are a bit shorter, because of the depth of the \strut. – Torbjørn T. Jul 21 '18 at 9:11
• @TorbjørnT. Thanks! Done! (The shorter legs at the beginning and end were on purpose but I added a description of how to make them longer.) – user121799 Jul 21 '18 at 13:49

Here's a way using the text effects along path decoration to typeset the url as individual nodes which can then be used to position the braces.

\documentclass[tikz,border=2]{standalone}
\usetikzlibrary{calc,decorations.pathreplacing,decorations.text}
\begin{document}
\begin{tikzpicture}
\path [decoration={
text effects along path,
text effects/.cd,
text along path,
path from text,
character count=\n,
every character/.style={
font=\tt, name=n\n,
text height=0.666em, text depth=0.125em,
minimum height=0}},
decorate] (0,0);
\foreach \i/\j/\name in {
1/8/Schema,9/41/Authority,42/52/Path,53/60/Query,61/66/Fragment}
\draw [decoration={brace, mirror, amplitude=6}, decorate]
($(n\i.south west)+(0.05,0)$) -- ($(n\j.south east)-(0.05,0)$)
node [midway, below=8, font=\scriptsize\sffamily] {\name};
\end{tikzpicture}
\end{document}