Math & Science ⇒ Reversed cases
Reversed cases
Hi all,
I need a new cases environment with the set parenthesis horizontally flipped and on the right-hand side. How is this possible?
Thanks.
bkarpuz
I need a new cases environment with the set parenthesis horizontally flipped and on the right-hand side. How is this possible?
Thanks.
bkarpuz
Last edited by bkarpuz on Mon May 16, 2011 10:59 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

-
- Posts: 7
- Joined: Sun May 15, 2011 11:33 pm
Re: Reversed cases
If I understand correctly, I think this may be what you are looking for:
http://www.latex-community.org/forum/vi ... =46&t=5269
http://www.latex-community.org/forum/vi ... =46&t=5269
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Reversed cases
Hi bkarpuz,
you could use a pair \left. and \right\} around an array, similar to the original cases environment, such as
or copy the original cases environment and modify it, if it should really look very similar, regarding alignment and spacing.
Stefan
you could use a pair \left. and \right\} around an array, similar to the original cases environment, such as
Code: Select all
\left.
\begin{array}{ll}
... & ... \\
... & ...
\end{array}
\right\}
Stefan
LaTeX.org admin
Reversed cases
Thank you Stefan_K.
I could do it as you gave in the codes but I want to learn the way you mention below.
I dont know where I can copy the original cases environment.
bkarpuz
I could do it as you gave in the codes but I want to learn the way you mention below.
I dont know where I can copy the original cases environment.
Thanks.Stefan_K wrote:Hi bkarpuz,
or copy the original cases environment and modify it, if it should really look very similar, regarding alignment and spacing.
Stefan
bkarpuz
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Reversed cases
It may look a bit difficult, since the amsmath package is quite sophisticated. However, here's a short straightforward way:
1. The original code is in amsmath.sty:
2.-4. We need to redefine both macros, since the first contains the left brace, the second contains the right one. The result of the steps in your preamble can be:
Many lines of code, but it's following the simple steps, the final modification has been just changing \lbrace to . and . to \rbrace.
Stefan
- Look for the original code.
- Copy it in your own document preamble.
- Replay \def, \newcommand and alike by \renewcommand or \renewcommand* and its syntax. Though you could also stay with \def, it's just TeX, not LaTeX.
- If there's an @ in that code, use \makeatletter before and \makeatother after.
- Change the definition as desired.
1. The original code is in amsmath.sty:
Code: Select all
\renewenvironment{cases}{%
\matrix@check\cases\env@cases
}{%
\endarray\right.%
}
\def\env@cases{%
\let\@ifnextchar\new@ifnextchar
\left\lbrace
\def\arraystretch{1.2}%
\array{@{}l@{\quad}l@{}}%
}
Code: Select all
\makeatletter
\renewenvironment{cases}{%
\matrix@check\cases\env@cases
}{%
\endarray\right\rbrace%
}
\def\env@cases{%
\let\@ifnextchar\new@ifnextchar
\left.
\def\arraystretch{1.2}%
\array{@{}l@{\quad}l@{}}%
}
\makeatother
Stefan
LaTeX.org admin
Reversed cases
Hi again Stefan_K, I really appreciate what you have shown me.
Thanks.
bkarpuz
Thanks.
bkarpuz
Stefan_K wrote:It may look a bit difficult, since the amsmath package is quite sophisticated. However, here's a short straightforward way:
...
- Look for the original code.
- Copy it in your own document preamble.
- Replay \def, \newcommand and alike by \renewcommand or \renewcommand* and its syntax. Though you could also stay with \def, it's just TeX, not LaTeX.
- If there's an @ in that code, use \makeatletter before and \makeatother after.
- Change the definition as desired.
Stefan
Reversed cases
How can I define a new environment rcases (reversed cases) to use both cases and rcases in my codes?
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Reversed cases
Define new macros instead of redefining existing. It's very similar:
Stefan
Code: Select all
\makeatletter
\newenvironment{rcases}{%
\matrix@check\cases\env@rcases
}{%
\endarray\right\rbrace%
}
\def\env@rcases{%
\let\@ifnextchar\new@ifnextchar
\left.
\def\arraystretch{1.2}%
\array{@{}l@{\quad}l@{}}%
}
\makeatother
LaTeX.org admin
Reversed cases
Thanks a lot Stefan it seems that we only replace \renewenvironment with \newenvironment and some of the cases with rcases. But I got the following error while running your code.Stefan_K wrote:Define new macros instead of redefining existing. It's very similar:
StefanCode: Select all
\makeatletter \newenvironment{rcases}{% \matrix@check\cases\env@rcases }{% \endarray\right\rbrace% } \def\env@rcases{% \let\@ifnextchar\new@ifnextchar \left. \def\arraystretch{1.2}% \array{@{}l@{\quad}l@{}}% } \makeatother
Code: Select all
! Package amsmath Error: Old form `\cases' should be \begin{cases}.
See the amsmath package documentation for explanation.
Type H <return> for immediate help.
...
l.154 \begin{rcases}
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Reversed cases
I see! You also have to change cases to rcases for the call to \matrix@check, modify this line:
Now I remember the mathtools package provides an rcases environment for exactly this purpose. So, instead of our redefinition, loading mathtools is sufficient:
Stefan
Code: Select all
\matrix@check\rcases\env@rcases
Code: Select all
\usepackage{mathtools}
LaTeX.org admin