2

I've got this document class and these math libraries:

\documentclass[12pt,twoside,a4paper]{book}

\usepackage{amsmath} \usepackage{amsfonts} \usepackage{cancel}

I'm trying to make something like this:
What I want

This is the code I am using right now:

\[ \left.
    \begin{aligned}
        f(x) &= x - 1; \qquad x \in \left< 1;6 \right> \\
        g(x) &= \frac{x^2 - 1}{x + 1}; \quad ~ x \in \left< 1;6 \right>
    \end{aligned}
\qquad \right} f = g? \]

And this is the output:
This is the result

I couldn't find an answer to what I would like to achieve. The right brace doesn't show up and I worked around the alignment of the function input definition so it appears right below it. I tried \begin{array}{ll}, but then it doesn't align along the equality sign and it makes the fraction smaller, which is not what I want (and the right brace still doesn't work). I don't actually need to find a better way to align the function input definition next to equality sign aligned equations of functions (although it would be nice), but that non-functioning right brace does indeed bug me.

Polda18
  • 31
  • you must get an error from that, always ask about the error message not show the output, which is not intended to be usable after an error. \} not } to typeset } – David Carlisle Jan 09 '22 at 11:33
  • I'm an idiot :D Thanks, this is really stupid mistake :D – Polda18 Jan 09 '22 at 11:34
  • Note the mathtools package (a superset of amsmath) defines the rcases and drcases environments, which simplifies the code. – Bernard Jan 09 '22 at 11:46
  • Thanks for the tip, I'll look into it and find an example as to how to use it :) For now, I'll stick to this. – Polda18 Jan 09 '22 at 11:56

3 Answers3

5

I'd like to recommend that you employ a drcases environment, which is provided by the mathtools package.

Oh, and do please write \langle and \rangle instead of \left< and \right>. Even though using \left< and \right> to create angle brackets kind of "works" for sighted readers, i.e., for people whose eye sight is ok, it's discouraged nowadays. Why? If there's any chance at all that your document will one day be passed through software to make it accessible to unsighted people via voice screen reader software, the software will likely become utterly confused as to how to read \left< and \right> out loud. Please do not think that this possibility is remote. There are currently projects underway to make vast depositories of papers written in PlainTeX and LaTeX, some written years and even decades ago, accessible to unsighted readers via suitable screen reader software. Thus, do try to be thoughtful.

enter image description here

\documentclass[12pt,twoside,a4paper]{book}
\usepackage{mathtools} % for 'drcases' env.

\begin{document} [ \begin{drcases} f(x)=x-1 ,; & x\in\langle1;6\rangle \ g(x)=\frac{x^2-1}{x+1} ,; & x\in\langle1;6\rangle \end{drcases} f=g? ] \end{document}


If you truly prefer to pursue your approach, I'd suggest you employ an alignedat{2} environment instead of an aligned environment. No screenshot is presented as the output of the following code block is virtually identical to the screenshot shown above.

\[ 
\left.\begin{alignedat}{2}
        f(x) &= x - 1;                 &     & x \in \langle 1;6 \rangle \\
        g(x) &= \frac{x^2 - 1}{x + 1}; &\quad& x \in \langle 1;6 \rangle
      \end{alignedat}
\right\} 
f = g? 
\]
Mico
  • 506,678
  • @aahlback - Thanks for the suggested edit. I've accepted your suggestion, and then added some more explanatory material. – Mico Jan 10 '22 at 02:57
  • Well, I always tend to use \left# and \right# directives where # is the specified pair or parenthesis used ((),||,[],{},<>), so I guess you meant something like this: \left\langle 1;6 \right\rangle. It's because if I was to use a fraction inside, the suggested change wouldn't automatically change the parenthesis size. – Polda18 Mar 29 '22 at 13:23
  • 1
    @Polda18 - I'm not sure I fully "get" the thrust of your message. For sure, using \left and \right is not a panacea, and it's not costless from a typographic point of view either. See, e.g., Is it ever bad to use \left and \right? for an in-depth discussion of some of the associated issues. – Mico Mar 29 '22 at 14:22
  • I guess that makes sense for long and complicated equations, but for a simple real range using simple expressions? Using \left and \right is quite adequate. Pros are you don't have to experiment with sizing, it does automatically for you. Cons are it limits you in more complicated equations, which doesn't really matter in this case. – Polda18 Apr 01 '22 at 10:46
  • 1
    @Polda18 - You are, naturally, free to do whatever you want. The ubiquitous use of \left and \rightwill add a lot of typographically unnecessary whitespace padding. If that's something you would rather avoid, I'd like to suggest that you load the mleftright package and execute \mleftright in the preamble. – Mico Apr 01 '22 at 15:18
1

A solution with drcases from mathtools:

\documentclass[12pt,twoside,a4paper]{book}

\usepackage{mathtools} \usepackage{amssymb} \usepackage{cancel}

\begin{document}

[ \begin{drcases} f(x) = x - 1; & x \in \langle 1;6 \rangle \quad\ g(x) = \frac{x^2 - 1}{x + 1}; & x \in \langle 1;6 \rangle \end{drcases} \qquad f = g,? ]

\end{document}

enter image description here

Edit: loading empheq (which loads mathtools) we get almost the same result with the empheq environment:

   \begin{empheq}[right={\empheqrbrace \qquad f = g\,?}]{alignat* = 2}
            & f(x) = x - 1; &\quad & x ∈ \langle 1;6 \rangle \quad\\
             & g(x) = \frac{x² - 1}{x + 1}; & & x ∈ \langle 1;6 \rangle
   \end{empheq}
Bernard
  • 271,350
0

So thanks for comments, it was really that simple of fixing a simple mistake in code, which is to use \} instead of }:

\[ \left.
    \begin{aligned}
        f(x) &= x - 1; \qquad x \in \left< 1;6 \right> \\
        g(x) &= \frac{x^2 - 1}{x + 1}; \quad ~ x \in \left< 1;6 \right>
    \end{aligned}
\qquad \right\} f = g? \]

Now the output is exactly what I expected:
enter image description here

Bernard
  • 271,350
Polda18
  • 31