I have some fairly specific requirements. I'm trying to draw a "table" (in quotes because I don't necessarily care if I use the tabular environment) with captions (text) on the left, and associated content on the right. The "content" is tikz graphs and (in the last row) a code listing.
Here is what I have right now:
\begin{figure}
\caption{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.}
\begin{tabularx}{\textwidth}{X X}
\\[0.5em]
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. & \\[0.5em]
\\[0.5em]
\hline
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. &
\begin{tikzpicture}[framed]
\tikzset{vertex/.style = {shape=rectangle,draw,font=\footnotesize}}
\tikzset{edge/.style = {->,> = latex'}}
\node[vertex] (a) {lorem};
\end{tikzpicture}
\\[0.5em]
\hline
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. &
\begin{tikzpicture}[framed]
\tikzset{vertex/.style = {shape=rectangle,draw,font=\footnotesize}}
\tikzset{edge/.style = {->,> = latex'}}
\node[vertex] (a) at (0, 0) {lorem};
\node[vertex] (b) at (-1, 1) {ipsum};
\node[vertex] (c) at (1, 1) {dolor};
\draw[edge] (b) to (a);
\draw[edge] (c) to (a);
\end{tikzpicture}
\\[0.5em]
\hline
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. &
\begin{tikzpicture}[framed]
\tikzset{vertex/.style = {shape=rectangle,draw,font=\footnotesize}}
\tikzset{edge/.style = {->,> = latex'}}
\node[vertex] (a) at (0, 0) {lorem};
\node[vertex] (b) at (-1, 1) {ipsum};
\node[vertex] (c) at (1, 1) {dolor};
\node[vertex] (d) at (-1, 2) {sit};
\draw[edge] (b) to (a);
\draw[edge] (c) to (a);
\draw[edge] (d) to (b);
\end{tikzpicture}
\\[0.5em]
\hline
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. &
\begin{tikzpicture}[framed]
\tikzset{vertex/.style = {shape=rectangle,draw,font=\footnotesize}}
\tikzset{edge/.style = {->,> = latex'}}
\node[vertex] (a) at (0, 0) {lorem};
\node[vertex] (b) at (-1, 1) {ipsum};
\node[vertex] (c) at (1, 1) {dolor};
\node[vertex] (d) at (-1, 2) {sit};
\node[vertex] (e) at (1, 2) {amet};
\draw[edge] (b) to (a);
\draw[edge] (c) to (a);
\draw[edge] (d) to (b);
\draw[edge] (e) to (c);
\end{tikzpicture}
\\[0.5em]
\hline
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. &
\begin{tikzpicture}[framed]
\tikzset{vertex/.style = {shape=rectangle,draw,font=\footnotesize}}
\tikzset{edge/.style = {->,> = latex'}}
\node[vertex] (a) at (0, 0) {lorem};
\node[vertex] (b) at (-1, 1) {ipsum};
\node[vertex] (c) at (1, 1) {dolor};
\node[vertex] (d) at (-1, 2) {sit};
\node[vertex] (e) at (1, 2) {amet};
\node[vertex] (f) at (1, 3) {consectetur};
\draw[edge] (b) to (a);
\draw[edge] (c) to (a);
\draw[edge] (d) to (b);
\draw[edge] (e) to (c);
\draw[edge] (f) to (e);
\end{tikzpicture}
\\
\\[0.5em]
\hline
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. &
\begin{lstlisting}^^J
Lorem ipsum = Dolor.sit();^^J
Amet consectetur = adipiscing(elit);^^J
sed.do(eiusmod);^^J
^^J
\end{lstlisting}
\end{tabularx}
\end{figure}
The problem is, this renders like this:
The main problem here is that the content on the right isn't aligned with the caption on the left. The \hlines and the frames around the graphs are just here to illustrate, I don't want them in the final product, so it's hard to tell what goes with what, not to mention the table is much taller than it needs to be. It seems like the problem is that the captions aren't aligning to the top of their row.
How can I get what I'm looking for? My requirements are:
- Align caption and content in sensible way, ideally vertical center to vertical center.
- Use
tikzfor the graphs. - The code block in the last row should look like code, i.e. be in monospaced font.
- The whole thing is inside a
figure.
Beyond that, I don't mind what libraries or environments I use.


X) the baseline of the first row. For the Tikzpicture, it is the bottom of the bounding box/the picture. You can use thebaselineoption to set this to any y value or to the y value of a coordinate/anchor. For TikZbaseline=(current bounding box.center)centers the picture vertically. – Qrrbrbirlbel Nov 02 '22 at 16:44Xcolumn can be changed, too. (See the manual.) This question seems related. – Qrrbrbirlbel Nov 02 '22 at 16:48