0

In the exam document class, how to use EnvUplevel for solution that spans multiple pages? Here is my code. (It works perfectly if the solution is within a page) (I am using page size a5)

\documentclass[answers]{exam}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
% \Aboxed in the following
\usepackage{mathtools}

% page size \usepackage{geometry} \geometry{ papersize={140mm,210mm}, twoside=True, inner=15mm, outer=15mm, bindingoffset=7mm, top=20mm, bottom=22.5mm
}

\extrawidth{.5in}

\header{\oddeven{}{\thepage}}% {{\small 18MAT41 - Jan/Feb 2021}}% {\oddeven{\thepage}{}} \footer{}{{\small Visit entuition.org to unlock all QRs}}{}

\begin{document}

\begin{questions} % Question 1 % \renewcommand{\thequestion}{5} \question \begin{parts} % Question 1a \part Show that $w = \log z$, $z \neq 0$ is analytic and hence find $\displaystyle{dw \over dz}$.

% Solution 1a \begin{EnvUplevel} \begin{TheSolution} Given, [w = \log z \tag{1}] We know, [ z = r e^{i \theta} ] Substituting $z$ in (1), \begin{align} w &= \log ( r e^{i \theta}) \ w &= \log r + \log e^{i \theta} \ w &= \log r + i \theta \tag{2} \end{align} We know, [ w = u+ iv \tag{3}] Comparing (2) and (3), \begin{align} u &= \log r & v &= \theta \end{align} Partially differentiate with respect to $r$, \begin{align} u_r &= {1 \over r} & v_r &= 0 \tag{4} \end{align} Partially differentiate with respect to $\theta$, \begin{align} u_{\theta} &= 0 & v_{\theta} &= 1 \tag{5} \end{align} We know CR equations are, \begin{align} r u_r &= v_{\theta} \ r v_r &= -u_{\theta} \end{align} From (4) and (5), \begin{align} r u_r &= r \cdot {1 \over r} = 1 = v_\theta \ r v_r &= r \cdot 0 = 0 = -u_\theta \end{align} The CR equations are satisfied. Hence $w = \log z$ is analytic.\ We know, [{dw \over dz} = e^{-i \theta}(u_r + iv_r)] Substituting $u_r$ and $v_r$ from (4), \begin{align} {dw \over dz} &= e^{-i \theta} \left( {1 \over r} + i , 0 \right) \ {dw \over dz} &= {1 \over re^{i \theta}} \ \Aboxed{{dw \over dz} &= {1 \over z}} \end{align}

\end{TheSolution} \end{EnvUplevel}

\end{parts} \end{questions} \end{document}

1 Answers1

0

EnvUpLevel puts the contents into a \vbox, which cannot be broken. This uses a \trivlist.

\documentclass[answers]{exam}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
% \Aboxed in the following
\usepackage{mathtools}

% page size \usepackage{geometry} \geometry{ papersize={140mm,210mm}, twoside=True, inner=15mm, outer=15mm, bindingoffset=7mm, top=20mm, bottom=22.5mm }

\extrawidth{.5in}

\header{\oddeven{}{\thepage}}% {{\small 18MAT41 - Jan/Feb 2021}}% {\oddeven{\thepage}{}} \footer{}{{\small Visit entuition.org to unlock all QRs}}{}

% compute \leftmargin for each level \settowidth{\leftmargin}{10.\hskip\labelsep}% \edef\exammargini{\the\leftmargin}% \settowidth{\leftmargin}{(m)\hskip\labelsep}% \edef\exammarginii{\the\leftmargin}% \settowidth{\leftmargin}{vii.\hskip\labelsep}% \edef\exammarginiii{\the\leftmargin}% \settowidth{\leftmargin}{($\psi$)\hskip\labelsep}% \edef\exammarginiv{\the\leftmargin}%

\makeatletter \newenvironment{myuplevel}{\ifnum@listdepth>0 \leftmargin=\csname exammargin@roman@listdepth\endcsname\relax \advance@totalleftmargin-\leftmargin \fi \trivlist \ifnum@listdepth>0 \leftskip=-\csname exammargin@roman@listdepth\endcsname\relax \advance@listdepth-1 \fi \item}{\endtrivlist} \makeatother

\begin{document}

\begin{questions} % Question 1 % \renewcommand{\thequestion}{5} \question \begin{parts} % Question 1a \part Show that $w = \log z$, $z \neq 0$ is analytic and hence find $\displaystyle{dw \over dz}$.

% Solution 1a \begin{myuplevel} \begin{TheSolution} Given, [w = \log z \tag{1}] We know, [ z = r e^{i \theta} ] Substituting $z$ in (1), \begin{align} w &= \log ( r e^{i \theta}) \ w &= \log r + \log e^{i \theta} \ w &= \log r + i \theta \tag{2} \end{align} We know, [ w = u+ iv \tag{3}] Comparing (2) and (3), \begin{align} u &= \log r & v &= \theta \end{align} Partially differentiate with respect to $r$, \begin{align} u_r &= {1 \over r} & v_r &= 0 \tag{4} \end{align} Partially differentiate with respect to $\theta$, \begin{align} u_{\theta} &= 0 & v_{\theta} &= 1 \tag{5} \end{align} We know CR equations are, \begin{align} r u_r &= v_{\theta} \ r v_r &= -u_{\theta} \end{align} From (4) and (5), \begin{align} r u_r &= r \cdot {1 \over r} = 1 = v_\theta \ r v_r &= r \cdot 0 = 0 = -u_\theta \end{align} The CR equations are satisfied. Hence $w = \log z$ is analytic.\ We know, [{dw \over dz} = e^{-i \theta}(u_r + iv_r)] Substituting $u_r$ and $v_r$ from (4), \begin{align} {dw \over dz} &= e^{-i \theta} \left( {1 \over r} + i , 0 \right) \ {dw \over dz} &= {1 \over re^{i \theta}} \ \Aboxed{{dw \over dz} &= {1 \over z}} \end{align}

\end{TheSolution} \end{myuplevel}

\end{parts} \end{questions} \end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Thx @John! This answers my question very precisely. If I wanted to up-level the solution one more time, how to modify the environment you wrote. I tried nesting 'myuplevel' doesn't work. Thx again. – Hariprasad Soragaon May 28 '22 at 06:26
  • Actually, EnvUpLevel doesn't stack either, at least not accurately. Exam class recomputes \leftmargin for each level. Of course, \trivlist sets \leftmargin=0pt, so it is more obviously incorrect. A fullwidth version would be much easier to implement. – John Kormylo May 28 '22 at 15:55