# Use arbitrary amount of underlines + descriptions using TikZ on parts of words

This is an extension of this question. In linguistics, word analyses are often necessary and I think that TikZ is an excellent tool to bring some life, color, and most of all clarity to the scene. I do not possess the skill to accomplish this, therefore I have drawn up a sketch of what I would like to do.

Using the other question and the following sketch as starting point, I hope that some clever mind will come up with a flexible solution.

A Tentative List of Criteria

1. Braces target specific letters to wrap around UNACHIEVED
2. Braces (curly brackets) should be able to overlap each other UNACHIEVED
3. Brace distance to word should be variable (accomplished in other question)
4. Description distance to brace should be variable (accomplished see update Apr 2 2013)
5. Description should be flexible enough to place somewhere far from brace and connect to brace with a dotted line (or some type of line) (accomplished see update Apr 2 2013)
6. Braces should be able to be put above and below a word UNACHIEVED sort of see percusse's answer
7. Flexible and easy to apply to an entire paragraph of words (like the Our Father in Finnish, for example!) (TikZ calculates the width of braces from specified letters in word) UNACHIEVED

TikZ Word Analysis Example:

UPDATE Apr 2 2013: Criteria #4 and #5

I was able to meet criteria #4 and #5 today! It is a hack-job and could possibly be streamlined (looking for pro to do this!).

I took the code from the other question and added

• Variables
• adjust vertical (yshift=) location of text
• horizontal (xshift=) location of text
• adjust width of description (text width=)
• Counter
• auto node names
• relate descriptions to braces (using "text#" and "brace#") allowing easy way to connect descriptions to the correct braces

How it works

In order to add a brace to a word, you use the \tikzbrace command. The following shows the options and an example.

\tikzbrace[brace yshift]{word}{description}[text width=20ex][text yshift][text xshift]

e.g. in action * Note the redundant text width inside the variable (not sure how to fix this—see section "A bit of Confusion")

\tikzbrace[-1ex]{word}{Nom.Sg. Suffix -me}[text width=20ex][5ex][xshift=4cm]

A bit of Confusion

Note that the order of variables in the command \NewDocumentCommand are confusing and I had to experiment with the order of them a bit. Likely due to the order in which TikZ parses the parameters. I also have a redundant text width= option hardcoded, yet it is still necessary to include the text width= in the variable. Maybe someone knows how to fix this.

Why Am I Using TikZ-Dependency?

Two things must work:

• Reference entire words (for the literal translations) (above words)

AND

• Still have separate nodes starting/ending at specific letters. (below words)

This could be solved is somebody knows how to solve criterion #2 using letters as references (part of the flexibility of this project)

To Do

• Meet missing criteria (see checklist above, which I will update until solved)
• permit carriage return within descriptions (not working even when text width is set) Achieved (SOLUTION: Need align= parameter to the description node e.g. align=left)

\documentclass[]{beamer}
\usepackage{fontspec}
\usepackage{tikz-dependency}

\newcounter{mycounter}
\setcounter{mycounter}{1}

\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc}
\usepackage{xparse}

% TikZ Command for Brace
\NewDocumentCommand{\tikzbrace}{O{-2.5ex} m m O{} O{1ex} O{} O{0ex}}{%
\tikz[remember picture]\coordinate (left brace coord);%
#2%
\tikz[remember picture]\coordinate (right brace coord);%
\begin{tikzpicture}[remember picture,overlay,
transform canvas={yshift=#1}]
\draw [decoration={amplitude=1ex,brace},decorate,#4] %
(right brace coord) -- (left brace coord)
node [#6,xshift=#7,midway,below=#5,font=\scriptsize] (text\arabic{mycounter}) {#3};
\path (right brace coord) -- (left brace coord) node[midway,yshift=#1] (brace\arabic{mycounter}) {\stepcounter{mycounter}};
\end{tikzpicture}%
}

\begin{document}
\begin{frame}{Satz 1}
\begin{dependency}[edge style={red,densely dotted}]
\begin{deptext}
\tikzbrace[-1ex]{Isae}{Vater} \& meidän, \& joka \& \tikzbrace[-1ex]{olet}{2Psg} \& \tikzbrace[-1ex]{taiva}{-\emph{issa}=pl (sg -\emph{ssa}) Inessiv, ähnlich Lokativ, e.g. talossa "in dem Haus"}[text width=20ex][10ex][xshift=0cm]\tikzbrace[-1ex]{issa}{-issa=pl von -ssa Inessiv (ähnlich wie Lokativ). Trägt die Bedeutung „in“
z.B talossa=in the house
}[text width=20ex][5ex][xshift=4cm],\\
\end{deptext}
\deproot[edge unit distance=1ex]{1}{Vater}
\deproot[edge unit distance=1ex]{2}{unserer}
\deproot[edge unit distance=1ex]{3}{wer}
\end{dependency}
% Lines - Description to Brace
\begin{tikzpicture}[remember picture, overlay]
\draw[red, dotted] (text4.north) to [out=90,in=270](brace4.south);
\draw[red, dotted] (text3.north) to [out=90,in=270](brace3.south);
\end{tikzpicture}
\end{frame}
\end{document}

-
translation is a specific problem within the graphics so it covers almost all graphics questions. Hence it doesn't provide a good distinction from others. –  percusse Apr 2 '13 at 9:33
@percusse, I see what you mean. Is there any chance there could be a tag like "language-translation", something unique, which could be used to link questions regarding this topic? There are a number of questions ranging from columns to linguistics, which deal with translation but are as of now unlinked with a common tag. –  macmadness86 Apr 2 '13 at 10:14

You can use the same idea with different possibilities such as raise the decoration, or shift the coordinates use anchors etc.

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.pathmorphing,calc}
\begin{document}
\begin{tikzpicture}
\node[outer sep=0,inner sep=1pt] (w) {\Large Reenactment};
%The angle anchors
\draw[decoration={brace,raise=1mm},decorate,] (w.166) -- (w.13)
node[midway,above=2mm,align=center,anchor=south] {Some linguistic\\ text here};

% The explicit coord calc
\draw[decoration={brace,raise=1mm,mirror},decorate] (w.south west) -- ($(w.south)-(8mm,0)$)
coordinate [midway,below=2mm] (c1);
\draw[densely dashed] ([yshift=-2mm]c1) --++(0,-1cm) node[below] {Prefix-re};

\draw[decoration={brace,raise=20mm,mirror},decorate] (w.south west) -- (w.south);

\draw[decoration={brace,mirror},decorate]
([yshift=-3cm]w.south west) -- ([yshift=-3cm]w.south east);
\end{tikzpicture}
\end{document}


Node placement can be done via midway for the middle or pos=number option. Node displacement can be achieved by providing distance to above or below as arguments.

-
This solution is not integrated with the other question's code, nor is flexible (see starting point above). I should have defined flexible better. I will add to question. As it stands, your approach is arduous when dealing with an entire paragraph of words because you do not use letters as nodes, rather you have to calculate the distance each time. I will leave this unanswered for the time being. Nevertheless, great start. –  macmadness86 Apr 2 '13 at 9:58
@macmadness86 It would have been better if you had used a different example. These details are added after my answer. –  percusse Apr 2 '13 at 10:00
The additions do not really change much. The following: "Using the other question and the following sketch as starting point, I hope that some clever mind will come up with a flexible solution." was there all along (as were 5 of 7 criteria) and the other question uses letters as references for braces. –  macmadness86 Apr 2 '13 at 10:02