2

I'm submitting to a journal with a provided LaTeX template. They require examples to be done using ExPex. Many of my examples are in the form of TikzPicture "matrix of nodes" diagrams and tables. The default alignment for ExPex example numbers is at the top of the example (see #1 in the example below). The journal's stylesheet examples all have the example number aligned this way.

However, when I use tabular, the example number is aligned with the middle of the table (see #2). Worse yet, TikZ pictures appear entirely above the example number. I usually use [row sep=5mm], and thought that that might be affecting ExPex's alignment, however the same alignment appears with (#3) and without (#4) the custom row separation.

Is there any way to tell ExPex to align example numbers to the top of TikZ pictures and tabular environments? Another question provided a way to change the alignment of example numbers in ExPex globally (link), but unless I've misread the thread, I don't think it addresses the discrepancy between example numbering in different environments.

\documentclass{article}
\usepackage{expex}
\usepackage{tikz}
\usetikzlibrary{backgrounds,matrix,cd}
\tikzset{showall/.style={framed, every node/.style=draw}}
\begin{document}
\ex
 A multi-line \\ example.
\xe
\ex
\begin{tabular}{cccl}
    a & b & c \\
    d & e & f \\
    g & h & i  
    \end{tabular}
\xe
\ex 
\begin{tikzpicture}
 \matrix (m) [matrix of nodes, row sep=5mm] {
  a & b & c \\
  d & e & f \\
  g & h & i \\
  };
\end{tikzpicture} 
\xe
\ex 
\begin{tikzpicture}
 \matrix (m) [matrix of nodes] {
  a & b & c \\
  d & e & f \\
  g & h & i \\
  };
\end{tikzpicture} 
\xe
\end{document}

misaligned example numbers in expex

1

For tikzpicture you can use the baseline option. Fix it to any coordinate you want to use as reference. Following code shows one option. tikzpicture's background rectangle and matrix border are shown for reference.

For general alignment problems you can use adjustbox package.

\documentclass{article}
\usepackage{expex}
\usepackage{tikz}
\usetikzlibrary{backgrounds,matrix,cd}
\tikzset{showall/.style={framed, every node/.style=draw}}
\begin{document}
\ex
 A multi-line \\ example.
\xe
\ex
\begin{tabular}{cccl}
    a & b & c \\
    d & e & f \\
    g & h & i  
    \end{tabular}
\xe
\ex 
\begin{tikzpicture}[baseline={([yshift=-3mm]current bounding box.north)}, show background rectangle]
 \matrix (m) [matrix of nodes, draw=red, row sep=5mm] {
  a & b & c \\
  d & e & f \\
  g & h & i \\
  };
\end{tikzpicture} 
\xe
\ex 
\begin{tikzpicture}
 \matrix (m) [matrix of nodes] {
  a & b & c \\
  d & e & f \\
  g & h & i \\
  };
 \end{tikzpicture}
 \xe
 \end{document}

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.