2

Why do I get an error message with \par\xdef\tpd{\region\prevdepth} but not with \par\xdef\tpd{\the\prevdepth}?

\documentclass{amsart}
\usepackage{mathtools}

\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in} \setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}


\begin{document}


\noindent \begin{minipage}[t]{4.875in}
\noindent \textbf{1. }The following figure depicts three congruent semicircles bounded by another \\
semicircle; the diameters of the three smaller semicircles cover the diameter of \\
the bigger semicircle, and each of the three smaller semicircles is tangent to \\
two other semicircles at the endpoints of its diameter. \textit{A} is the area of the \\
region enclosed by the three smaller semicircles, and \textit{B} is the area of the \par\xdef\tpd{\region\prevdepth}
\end{minipage}
%
\hspace{-0.25cm}
%
\raisebox{0mm}[0mm][0mm]
{
\begin{tikzpicture}[baseline=(current bounding box.north west)]

\coordinate (O) at (0,0);
\draw[fill=blue!50] (-1.5,0) -- (1.5,0) arc (0:180:1.5) -- cycle;
%
\draw[fill=yellow] (-3/2,0) -- (-1/2,0) arc (0:180:1/2) -- cycle;
\draw[fill=yellow] (-1/2,0) -- (1/2,0) arc (0:180:1/2) -- cycle;
\draw[fill=yellow] (1/2,0) -- (3/2,0) arc (0:180:1/2) -- cycle;

\draw[fill] (O) circle (1.5pt);


\end{tikzpicture}
} \\
\prevdepth=\tpd
enclosed by the big semicircle but outside the three smaller semicircles. Compute the ratio of $A : B$.

\end{document}
  • 3
    The error is Undefined control sequence. because you have not defined \region. – Henri Menke Dec 18 '18 at 04:57
  • Btw: Never end lines/sentences with \\. – TeXnician Dec 18 '18 at 06:06
  • \the is a specific command, see https://tex.stackexchange.com/q/38674/4427 for more information. – egreg Dec 18 '18 at 07:48
  • \end{minipage} \hspace{-0.25cm} \raisebox makes a space that is -0.25cm less than the width of two interword spaces. If that is what you want then fine, but it seems a strange length to specoify. – David Carlisle Dec 18 '18 at 07:59
  • it only makes sense to query \prevdepth after a paragraph, and setting it mid-paragraph as you do here does not do anything useful as tex will set it once the paragraph finishes. – David Carlisle Dec 18 '18 at 08:01

2 Answers2

5
  1. You get an error because \region is not a defined command.

  2. A minipage with the t option has a very large depth, so the next line will be separated from it with \lineskip glue.

  3. If instead we measure the depth of the last line in the minipage, we can reinsert that depth prior to starting the next paragraph, so ensuring constant baseline skip.

  4. What's \tpd? Just a temporary macro. You could call it \depthofthelastlineintheminipage or whatever name you like, so long as it's not likely to be a used command.

  5. Why \xdef? Because minipage forms a group and a simple \def would not make the macro survive the end of the group.

  6. Why \xdef\tpd{\the\prevdepth}? Because we want to use the actual value of \prevdepth at the moment the definition is made; \xdef is the same as \global\edef and so \the will be expanded. See The \the command for more information on \the.

egreg
  • 1,121,712
3

You have not defined the macro \region in your document and it is not provided by any of the included packages. The \xdef definition

\xdef\tpd{\region\prevdepth}

forces full expansion of its replacement text for which the definition of \region is needed. If \region is undefined at that point you will get an error ! Undefined control sequence.. This is in contrast to a regular \def definition like

\def\tpd{\region\prevdepth}

where the definition of the tokens in the replacement text only has to known when \tpd is actually expanded.

Read chapter 20 “Definition (also called Macros)” in the TeXbook for more details.

Henri Menke
  • 109,596