I want to make a subnumcases
-like environment, named mynumcases
, like this
I will explain what I want and what I have tried.
- what I want:
- equations in
mynumcases
have a parent counter which is same asequation
- I want to put this parent counter before the big brace, and has a fixed length away from left margin (I don't know what the left line's name), this length doesn't need to set as an argument.
\Roman
parent counter and\alph
child counter- (option) I can make my own tag at the position of the parent counter
what I have tried
- I refered this answer: https://tex.stackexchange.com/a/343157/180617
- I found I can't use this method in my demand.
- I tried to use
empheq
package's[left=...]
argument.
Here is my code:
\documentclass{article}
\usepackage{amsmath, environ}
\usepackage{empheq}
\usepackage[showframe]{geometry}
\makeatletter
\def\Rom{\@Roman}
\NewEnviron{mynumcases}[2][\@nil]{%
\def\tmp@ne{#1}
\refstepcounter{equation}
\edef\oldeqnum{\theequation}
\setcounter{equation}{0}
\renewcommand{\theequation}{\alph{equation}}
\begin{empheq}[left={\makebox[0pt][r]{\makebox[.3\linewidth][l]{\ifx\tmp@ne\@nnil (\Rom{\oldeqnum}) \else #1 \fi}}#2\empheqlbrace}]{align}
\BODY
\end{empheq}
\setcounter{equation}{\oldeqnum}
}
\makeatother
\begin{document}
first equation
\begin{equation}
1 + 1 = 2
\end{equation}
first mynumcases
\begin{mynumcases}{}
& 1 + 1 = 2\\
& 1 = 1
\end{mynumcases}
another equation
\begin{equation}
test
\end{equation}
second mynumcases
\begin{mynumcases}{f(x)=}
& 1+1+1+1+1 & \text{if } hello\\
& 1 + 1 & \text{if } hello\\
& 1 & \text{if } hello\\
& 1
\end{mynumcases}
third mynumcases
\begin{mynumcases}[my words]{f(x)=}
& 1+1+1+1+1\\
& 1 + 1\\
& 1
\end{mynumcases}
\end{document}
and the whole output
And we can notice that
- the parent counter has the fixed length away from the equation, not left margin
- I have to put
&
before every line to make it align left if hello
is far away from1+1..
How can I reach my demand? Does anyone have ideas?