4

Being new in LaTeX I don't know where to look for the proper resources. I know this is probably documented for easily somewhere out there, but I'm struggling with knowing where to look - any help isappreciated.

How would you reproduce in LaTeX this conditional expression with one curly brace on the left side?

This is what I'm trying to reproduce

GiuTeX
  • 1,309

3 Answers3

8
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
  t(v) =
  \begin{cases}
    \text{John} & \text{hvis $v$ er variabelen $x$}\\
    \text{Paul} & \text{hvis $v$ er variabelen $y$}\\
    \text{George} & \text{hvis $v$ er variabelen $z$}\\
    \text{Yoko} & \text{ellers}
  \end{cases}
\]
\end{document}

enter image description here

Jendrik notes in the comments that the cases* environment, available with mathtools, sets the right-hand alignment automatically as text, rather than math, which is useful in this situation. Thus, the cases* equivalent of the above code would be

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
  t(v) =
  \begin{cases*}
    \text{John} & hvis $v$ er variabelen $x$\\
    \text{Paul} & hvis $v$ er variabelen $y$\\
    \text{George} & hvis $v$ er variabelen $z$\\
    \text{Yoko} & ellers
  \end{cases*}
\]
\end{document}

Here's an alternative with tabstackengine, allowing the content to be set in text mode directly:

\documentclass{article}
\usepackage{tabstackengine}
\begin{document}
\[
  \setstackgap{L}{1.1\normalbaselineskip}% ROW BASELINESKIP
  \setstacktabbedgap{1em}% INTER-COLUMN GAP
  t(v) = \left\{
    \tabbedCenterstack[l]{% LEFT ALIGNED STACK CONTENT
    John & hvis $v$ er variabelen $x$\\
    Paul & hvis $v$ er variabelen $y$\\
    George & hvis $v$ er variabelen $z$\\
    Yoko & ellers
    }
  \right.
\]
\end{document}
4

Another solution with just array and bigdelim:

\documentclass{article}
\usepackage{bigdelim, array}

\begin{document}

\begin{center} \sffamily \begin{tabular}{l@{,}l@{\quad}l} \ldelim{{4}{*}[$t(v)={}$] & John & hvis $v$ er variabelen $x$ \ & Paul & hvis $v$ er variabelen $y$ \ & George & hvis $v$ er variabelen $z$ \ & Yoko & ellers \end{tabular} \end{center}

\end{document}

enter image description here

Bernard
  • 271,350
3

Steven has already said enough, but just for completeness and for proving that LaTeX offers always new roads I'll post another solution by means of .., though I think cases environment is the most appropriate for this job.

\documentclass{article}
\usepackage{amsmath}

\begin{document} [ t(v) = \left{\begin{array}{lr} \text{John} & \text{hvis $v$ er variabelen $x$}\ \text{Paul} & \text{hvis $v$ er variabelen $y$}\ \text{George} & \text{hvis $v$ er variabelen $z$}\ \text{Yoko} & \text{ellers} \end{array}\right. ] \end{document}

This produces

With array

Notice that amsmath package is only needed for text command. A benefit from using array would be that you can control alignment by means of r and l (respectively right aligned, and left aligned) arguments in \begin{array}{lr}, and you can add lines as well as control manually spacing, by writing

\[
    t(v) = \left\{\begin{array}{l@{\hspace{3em}}|r}
        \text{John} & \text{hvis $v$ er variabelen $x$}\\
        \hline
        \text{Paul} & \text{hvis $v$ er variabelen $y$}\\
        \text{George} & \text{hvis $v$ er variabelen $z$}\\
        \text{Yoko} & \text{ellers}
    \end{array}\right.
\]

@{\hspace{3em}} can be set to whichever value in em, cm, pt and other measure you like for making custom space between columns, while | can be used for adding vertical lines bewreen the arry columns. Finally adding \hline you can achieve horizontal rules.

Little addendum: \left\{ and \right. fake the case behaviour of cases environment, so that if you prefer you can switch it to othe parenthesis, as [, (, \langle and so on.

GiuTeX
  • 1,309