# Horizontal curly braces in ExPex glossing example

This code, with line 52 not commented out, but line 53 commented out:

\documentclass{report}
% 07Examples.txt - New Early Babbish Gramamr
\usepackage{fontspec}
\usepackage{titlesec}
\usepackage{expex}
\usepackage{keyval}
\usepackage[letterpaper]{geometry}
\usepackage{amsmath}

\geometry{height=10in,top=0.625in,width=6.5in,left=0.75in,showframe}

\setcounter{secnumdepth}{3}
\setcounter{secnumdepth}{4}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{4}

\titleformat{\paragraph} [hang] {\normalfont\normalsize\bfseries}
{\theparagraph} {1em} {}

\definelingstyle{EarlyBabbish}{glspace=1.5em,everygla=\large,
everyglb=\large,aboveglbskip=-.2ex,everyglft=\large\bfseries}

\definelingstyle{subsub}{\large}
\definelingstyle{sub}{\normalsize}
\definelingstyle{sec}{\large}

\begin{document}
\lingset{exskip=0ex,sampleexno=50.10.10.10}
\setcounter{chapter}{6}
\chapter{Example Repository}
\renewcommand{\thechapter}{\arabic{chapter}}
\setcounter{section}{49}
\renewcommand{\thesection}{\arabic{section}}
\section[lingstyle=sec]{Examples Referenced Elsewhere}
\setcounter{subsection}{-1}
\subsection[lingstyle=sub]{Examples from Chapter 1, Phonology and Nouns}
\setcounter{subsubsection}{3}
\subsubsection[lingstyle=subsub]{Gloss of something}
\ex~[lingstyle=EarlyBabbish,exno=1]
\begingl
\gla luizcid dun- @ ua- @ glud- @ \O @ gan giumima //
\glb ART PFX PFX V SFX SFX N //
\glb TOP.ERG ATEL-  NPST-  be.old-  ACT-  VST.PTCP woman //
\glb[\it] {there was a} {being old} {} {} {} {} {woman who} //
%line 53 \glb[\it] $\underbrace{{there was a} {being old} {} {} {} {}% % {woman who}}_\text{Ergative subject of verb muiddrin}$ //
\endgl
\xe
\end{document}


Typesets fine, with \glb texts, including "there was a", "being old" and "woman who", aligned under the appropriate words on the \gla line.

But when line 52 is commented out and line 53 uncommented, it places an underbrace below the "there was a", etc, but squishes all the text on that line together with no discernible space, and the underbrace encompasses this mashed together thing with no regard for the horizontal spacing implied by the preceding \glb and \gla macros.

I realize plopping the underbrace stuff in the middle of the text being typeset by \glb probably gaks ExPex, but how else to accomplish this notation?

BTW I did read all of the questions relating to horizontal braces, and did not see one that mentioned this particular problem.

The following images illustrate the results of switching lines 52 and 53 off and on, as well how a page with a similar gloss is more or less intended to look as done with Libre Office writer. (I removed the special font crap, and a whole lot of other stuff, from the TeX version, to make the example simpler.)

Interlinear gloss without horizontal curly brace:

Interlinear gloss with horizontal curly brace (and gakked):

Line 50.1.4.1(1) is how the typeset version of "interlinear gloss with curly brace" should look (as done by Libre Office writer)

I abandoned Word and writer in favor of LaTeX, but am a newbie with LaTeX and have been floundering somewhat.

• The \underbrace looked so promising, exactly what I wanted if only it had worked. TikZ was going to be my next stop. I haven't had a chance to try out @Alan-Munn's code, but it looks boss. Assuming it doesn't develop unseemly warts later on, I think it is the solution to my problem. Feb 27, 2017 at 19:19

There are various problems with what you have tried to do. First of all, the $\underbrace{ .... }$ command puts the text inside in math mode, which you don't want. But ExPex can't see inside the command anyway and treats it as a single word which is why the spacing is totally messed up.

I would use TikZ to do this sort of bracing. It gives you more flexibility on placement and is not restricted to math mode.

I've created three commands: one to place anchors for the brace \tikzmark, and one to place the braces themselves \tikzbrace. One places a brace with text underneath, and the other places a brace with text both below and above. The latter commands have an optional argument to offset the brace lower for nested brace structures.

\tikzmark{A} % creates an anchor named A
\tikzmark{B} % creates an anchor named B

\tikzbrace{A}{B}{Some text} % puts a brace between A and B with "Some text".
\tikzbrace[<offset>]{A}{B}{Some text} % puts a brace with an <offset> in pt

\overunderbrace[<offset>]{A}{B}{over text}{under text}


Here's the full example. You will need to compile the document twice because of the way TikZ remembers the placement of the anchors, so don't be worried if the first compilation looks strange.

\documentclass{report}
% 07Examples.txt - New Early Babbish Gramamr
\usepackage{fontspec}
\usepackage{titlesec}
\usepackage{expex}
\usepackage{keyval}
\usepackage[letterpaper]{geometry}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc}
\newlength{\braceamp}
\newlength{\uptextlen}
\setlength{\braceamp}{5pt}
\setlength{\uptextlen}{8pt}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture,auto,yshift=-3pt] \coordinate (#1);}
\newcommand{\tikzbrace}[4][0]{\tikz[overlay,remember picture]\draw [thick,decorate,decoration={brace,amplitude=\braceamp,mirror}]  ($(#2.west)+ (0,-#1pt)$) -- ($(#3.east)+(0,-#1pt)$)  node[midway,yshift=-2.5\braceamp] {#4};}
\newcommand{\overunderbrace}[5][0]{\tikz[overlay,remember picture]\draw [thick,decorate,decoration={brace,amplitude=\braceamp,mirror}]  ($(#2.west)+ (0,-#1pt)$) -- ($(#3.east)+(0,-#1pt)$)  node[midway,yshift=-2.5\braceamp] {#5} node [midway, yshift=\uptextlen] {#4};}

\geometry{height=10in,top=0.625in,width=6.5in,left=0.75in,showframe}

\setcounter{secnumdepth}{3}
\setcounter{secnumdepth}{4}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{4}

\titleformat{\paragraph} [hang] {\normalfont\normalsize\bfseries}
{\theparagraph} {1em} {}

\definelingstyle{EarlyBabbish}{glspace=1.5em,everygla=\large,
everyglb=\large,aboveglbskip=-.2ex,everyglft=\large\bfseries}

\definelingstyle{subsub}{\large}
\definelingstyle{sub}{\normalsize}
\definelingstyle{sec}{\large}

\begin{document}
\lingset{exskip=0ex,sampleexno=50.10.10.10}
\setcounter{chapter}{6}
\chapter{Example Repository}
\renewcommand{\thechapter}{\arabic{chapter}}
\setcounter{section}{49}
\renewcommand{\thesection}{\arabic{section}}
\section[lingstyle=sec]{Examples Referenced Elsewhere}
\setcounter{subsection}{-1}
\subsection[lingstyle=sub]{Examples from Chapter 1, Phonology and Nouns}
\setcounter{subsubsection}{3}
\subsubsection[lingstyle=subsub]{Gloss of something}
\ex~[lingstyle=EarlyBabbish,exno=1]
\begingl
\gla luizcid dun- @ ua- @ glud- @ \O @ gan giumima //
\glb ART PFX PFX V SFX SFX N //
\glb TOP.ERG ATEL-  NPST-  be.old-  ACT-  VST.PTCP woman //
\glb[\it] \tikzmark{A}{there was a} \tikzmark{C}{being old}\tikzmark{D} {} {} {} {} {woman who}\tikzmark{B} //
\endgl
\xe
\tikzbrace{C}{D}{Something else}
\tikzbrace[25]{A}{B}{Ergative subject of muiddrin}
\overunderbrace[60]{A}{B}{Over text}{Under text}
\end{document}


• Could the person who downvoted possibly explain why? Feb 27, 2017 at 16:38
• Yes, this is an excellent, simple answer (+1). I'm also curious about why it was downvoted. Feb 27, 2017 at 16:43
• I made my first reply to this answer in the wrong place, shoulda been here. One thing I like about this solution is that in Libre Office, I had to draw a horizontal curly brace (gads, isn't there an abbreviaton for that?) as a jpg, which then required either multiple versions depending on the width of the text being embraced, or just scaling it through Format-Image. Which was kinda successful, but as the jpg was stretched out, its warts became more prominent, and so looked inconsistent from text to text. This on-the-fly graphics look a lot better. Feb 27, 2017 at 19:27
• The answer AFAIC is excellent and deserving of up, not down, votes. Feb 27, 2017 at 19:29