Math & Science ⇒ Reversed cases
Reversed cases
I need a new cases environment with the set parenthesis horizontally flipped and on the right-hand side. How is this possible?
Thanks.
bkarpuz
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
-
- Posts: 7
- Joined: Sun May 15, 2011 11:33 pm
Re: Reversed cases
http://www.latex-community.org/forum/vi ... =46&t=5269
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Reversed cases
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
Reversed cases
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: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Reversed cases
- 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
Reversed cases
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
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Reversed cases
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
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: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Reversed cases
Code: Select all
\matrix@check\rcases\env@rcases
Code: Select all
\usepackage{mathtools}