1

I found this example in another paper that I want to emulate, if possible:

Aligned formula example

How do I have a three-column layout like that, where the middle column aligns all the formulas on their first operator? I've looked at various questions/answers related to mixing alignment environments with tables, but nothing I've found seems to work quite like this.

shader
  • 111
  • 2

3 Answers3

2
\documentclass{article}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\begin{document}

\begin{tabular}{lr@{$\mskip\thickmuskip$}c@{$\mskip\thickmuskip$}ll}
  \multicolumn{2}{l}{\textbf{Serverless  Functions}}  &            & \multicolumn{2}{l}{$\langle f, \Sigma, \mathsf{recv}, \mathsf{step}_f, \mathsf{init} \rangle$} \\
  Functions                       & $F$               & $\coloneq$ & $\cdots$                                                                                       \\
  Function name                   & $f$               & $\in$      & $F$                                                                                            \\
  Internal states                 & $\Sigma$          & $\coloneq$ & $\cdots$                                                                                       \\
  Initial state                   & $\mathsf{init}$   & $\in$      & $F \to \Sigma$                                                                                 \\
  Receive event                   & $\mathsf{recv}_f$ & $\in$      & $v \times \Sigma \to \Sigma$                                                                   \\
  Internal step                   & $\mathsf{step}_f$ & $\in$      & $F \times \Sigma \to \Sigma \times t$ & With  effect $t$                                       \\
  Values                          & $v$               & $\coloneq$ & $\cdots$                              & \textsc{json}, \textsc{http}, etc.                     \\
  Commands                        & $t$               & $\coloneq$ & $\varepsilon$                                                                                  \\
                                  &                   & $\vert$    & $\mathbf{return}(v)$                  &   Return  value                                        \\
\end{tabular}

\end{document}

enter image description here

Henri Menke
  • 109,596
2

A small variation of @Henri Menke answer (+1) with use tabularray package:

\documentclass{article}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{tabularray}

\begin{document} \begin{tblr}{colspec = {l Q[r,$] @{;} Q[l,$] l}, rowsep = 1pt, row{1} = {font=\bfseries} } \SetCell[c=2]{l} Serverless Functions & & \SetCell[c=2]{c}
\langle f, \Sigma, \mathsf{recv}, \mathsf{step}_f, \mathsf{init} \rangle
& \ Functions
& F & \coloneq\cdots & \ Function name
& f & \in F & \ Internal states
& \Sigma & \coloneq \cdots & \ Initial state
& \mathsf{init} & \in F \to \Sigma & \ Receive event & \mathsf{recv}_f & \in v \times \Sigma \to \Sigma & \ Internal step
& \mathsf{step}_f & \in F \times \Sigma \to \Sigma \times t & With effect $t$ \ Values & v & \coloneq \cdots & \textsc{json}, \textsc{http}, etc. \ Commands
& t & \coloneq \varepsilon
& \ & & \vert\quad \mathbf{return}(v) & Return value \ \end{tblr} \end{document}

enter image description here

Edit: Above solution work fine with tabularray newest package version version (after 2021N). For older packages versions, for example as is temporary available in Overleaf, unfortunately doesn't work (since math environment in columns are not yet defined). So, you need to use approach with local defining math environments: for example:

\documentclass{article}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{tabularray}

\begin{document} \begin{tblr}{colspec = {l Q[r] @{;} Q[l] l}, rowsep = 1pt, row{1} = {font=\bfseries} } \SetCell[c=2]{l} Serverless Functions & & \SetCell[c=2]{c} $\langle f, \Sigma, \mathsf{recv}, \mathsf{step}_f, \mathsf{init} \rangle$
& \ Functions & $F$ & $\coloneq\cdots$ & \ Function name & $f$ & $\in F$ & \ Internal states & $\Sigma$ & $\coloneq \cdots$ & \ Initial state & $\mathsf{init}$ & $\in F \to \Sigma$& \ Receive event & $\mathsf{recv}_f$ & $\in v \times \Sigma \to \Sigma$ & \ Internal step & $\mathsf{step}_f$ & $\in F \times \Sigma \to \Sigma \times t$ & With effect $t$ \ Values & $v$ & $\coloneq \cdots$ & \textsc{json}, \textsc{http}, etc. \ Commands & $t$ & $\coloneq \varepsilon$ & \ & & $\vert\quad \mathbf{return}(v)$ & Return value \ \end{tblr} \end{document}

Which gives the same result as the first MWE, however advantages to define of "math columns" are lost.

New version of tabularray is expected to be available around June (after published of the TeXlive 2022).

Zarko
  • 296,517
  • Pasting your code directly into a blank Overleaf document using pdfLaTeX and Texlive 2021 produces a ton of errors... – shader Apr 05 '22 at 21:19
  • @shader, indeed. Overleaf use old version of the tabullarray package which doesn't support math columns. Sorry. You not mentioned that you use Overleaf. In local installation of LaTeX (MiKTeX or TeXlive) with recent version of tabularray (2022A) works fine. It may be a time to make local installation of LaTeX ... – Zarko Apr 05 '22 at 23:14
  • @shader, se edited answer. – Zarko Apr 05 '22 at 23:30
0

Here's a solution using just the amsmath align environment. The spacing of the mathematical elements in the first line isn't exactly what you were looking for, but perhaps it is adequate.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
  &\text{\textbf{Serverless Functions}} ~  &  \qquad &\langle f, \Sigma,
      \text{\textbf{recv}}, \text{\textbf{step}}_f, \text{\textbf{init}} \rangle \\
  &\text{Functions}       & F                      &:=  \cdots                                                                 \\
  &\text{Function name}   & f                      &\in F                                                                      \\
  &\text{Internal states} & \Sigma                 &:= \cdots                                                                  \\
  &\text{Initial state}   & \text{\textbf{init}}   &\in F \rightarrow \Sigma                                                   \\
  & \text{Receive event}  & \text{\textbf{recv}}_f &\in v \times \Sigma \rightarrow \Sigma                                     \\
  & \text{Internal step}  & \text{\textbf{step}}_f &\in F \times \Sigma \rightarrow \Sigma \times t & &\text{With effect $t$}  \\
  & \text{Values}         & v                      &:= \cdots                                       & &\text{JSON, HTTP, etc.} \\
  & \text{Commands}       & t                      &:= \varepsilon                                                             \\
  &                       &                        &| \text{\quad \textbf{return}$(v)$}             & &\text{Return value}
\end{align*}
\end{document}

enter image description here