0

I can not put the commutative diagram under the frame:

\documentclass{amsart}
\usepackage{latexsym,amsmath}
\usepackage{tabularx, environ}
\usepackage{wasysym,latexsym,amsmath,amssymb,mathrsfs}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{mathtools}
\newcommand{\one}{\mathbf{1}}

\usepackage{scalerel,stackengine} \usepackage{tikz-cd} \usepackage{pst-node} \DeclareMathOperator{\id}{id} \stackMath \newcommand\reallywidehat[1]{% \savestack{\tmpbox}{\stretchto{% \scaleto{% \scalerel*[\widthof{\ensuremath{#1}}]{\kern-.6pt\bigwedge\kern-.6pt}% {\rule[-\textheight/2]{1ex}{\textheight}}%WIDTH-LIMITED BIG WEDGE }{\textheight}% }{0.5ex}}% \stackon[1pt]{#1}{\tmpbox}% } \parskip 1ex

\newtheorem{theorem}{Theorem} \newtheorem{corollary}{Corollary}[theorem] \newtheorem{lemma}[theorem]{Lemma} \newtheorem{definition}{Definition}[theorem] \newtheorem{remark}{Remark}[theorem] \newtheorem{question}{Question}[theorem] \newtheorem{solution}{Solution}[theorem] \makeatletter

% https://tex.stackexchange.com/a/199244/26355 \newcolumntype{\expand}{} \long@namedef{NC@rewrite@\string\expand}{\expandafter\NC@find} \NewEnviron{problem}[2][]{% \def\problem@arg{#1}% \def\problem@framed{framed}% \def\problem@lined{lined}% \def\problem@doublelined{doublelined}% \ifx\problem@arg@empty% \def\problem@hline{}% \else% \ifx\problem@arg\problem@doublelined% \def\problem@hline{\hline\hline}% \else% \def\problem@hline{\hline}% \fi% \fi% \ifx\problem@arg\problem@framed% \def\problem@tablelayout{|>{\bfseries}lX|c}% \def\problem@title{\multicolumn{2}{|l|}{% \raisebox{-\fboxsep}{\textsc{\Large #2}}% }}% \else \def\problem@tablelayout{>{\bfseries}lXc}% \def\problem@title{\multicolumn{2}{l}{% \raisebox{-\fboxsep}{\textsc{\Large #2}}% }}% \fi% \bigskip\par\noindent% \renewcommand{\arraystretch}{1.2}% \begin{tabularx}{\textwidth}{\expand\problem@tablelayout}% \problem@hline% \problem@title\[2\fboxsep]% \BODY\\problem@hline% \end{tabularx}% \medskip\par% } \makeatother \newenvironment{subproof}[1][\proofname]{% \renewcommand{\qedsymbol}{$\blacksquare$}% \begin{proof}[#1]% }{% \end{proof}% } \newcolumntype{\expand}{} \long@namedef{NC@rewrite@\string\expand}{\expandafter\NC@find} \NewEnviron{problem}[2][]{% \def\problem@arg{#1}% \def\problem@framed{framed}% \def\problem@lined{lined}% \def\problem@doublelined{doublelined}% \ifx\problem@arg@empty% \def\problem@hline{}% \else% \ifx\problem@arg\problem@doublelined% \def\problem@hline{\hline\hline}% \else% \def\problem@hline{\hline}% \fi% \fi% \ifx\problem@arg\problem@framed% \def\problem@tablelayout{|>{\bfseries}lX|c}% \def\problem@title{\multicolumn{2}{|l|}{% \raisebox{-\fboxsep}{\textsc{\Large #2}}% }}% \else \def\problem@tablelayout{>{\bfseries}lXc}% \def\problem@title{\multicolumn{2}{l}{% \raisebox{-\fboxsep}{\textsc{\Large #2}}% }}% \fi% \bigskip\par\noindent% \renewcommand{\arraystretch}{1.2}% \begin{tabularx}{\textwidth}{\expand\problem@tablelayout}% \problem@hline% \problem@title\[2\fboxsep]% \BODY\\problem@hline% \end{tabularx}% \medskip\par% } \makeatother \newenvironment{subproof}[1][\proofname]{% \renewcommand{\qedsymbol}{$\blacksquare$}% \begin{proof}[#1]% }{% \end{proof}% } \usepackage{tikz-cd}

\begin{document} \begin{problem}[framed]{Question 2} %Task: & Define a new ``problem'' environment. \ Problem: & Show that any two terminal objects are isomorphic. Specifically, if $\mathbf{1}$ and $\mathbf{1}^{\prime}$ are both terminal objects, show that there are arrows $f: \mathbf{1} \rightarrow \mathbf{1}^{\prime}$ and $g: \mathbf{1}^{\prime} \rightarrow \mathbf{1}$ such that $g \circ f=\mathrm{id}{1}$ and $f \circ g=\mathrm{id}{1}$. This is what it means for two objects to be isomorphic in a category.\ Solution: & As, $\mathbf{1},\mathbf{1}^{\prime}$ are terminal objects. From $\mathbf{1} \to \mathbf{1}^{\prime}, \mathbf{1} \to \mathbf{1}$ we have a unique map so are from $\mathbf{1}^{\prime} \to \mathbf{1}, \mathbf{1}^{\prime}\to \mathbf{1}^{\prime}$. Then we have maps $f \circ g: \mathbf{1}^{\prime} \to \mathbf{1}^{\prime}$ and $g \circ f: \mathbf{1} \to \mathbf{1}.$ Now $id|{\mathbf{1}^{\prime}}:\mathbf{1}^{\prime} \to \mathbf{1}^{\prime}$ and $id|{\mathbf{1}}:\mathbf{1} \to \mathbf{1}$ are also maps then $g \circ f=id_{\mathbf{1}}$ and $f \circ g=id_{\mathbf{1}^{\prime}}.$ \end{problem}

\begin{problem}[framed]{Question 5} %Task: & Define a new ``problem'' environment. \ Problem: & "Let $\mathbf{C}$ be a category with terminal object $\mathbf{1}$. Let $X$ be an object of $\mathbf{C}$. We will prove that $X \times 1$ is isomorphic to $X$.

(a) Because $X \times 1$ is the product of $X$ and 1 , it comes with two arrows. Describe them by stating their domain and codomains.

(b) There is another object with arrows to both $X$ and 1 . What is it? What are the arrows?

(c) Use the existence property of products to find a right-inverse u for the arrow $\pi_{X}: X \times \mathbf{1} \rightarrow X .$

(d) Now we want to show that $u$ is a left-inverse to $\pi_{X}$ as well. To that end, name one arrow $f: X \times \mathbf{1} \rightarrow X \times \mathbf{1}$ so that the following diagram commutes, meaning that $\pi_{X} \circ f=\pi_{X} .$ \end{problem} [ \begin{tikzcd}[row sep=huge] & X\times \textbf{1}\ar[dl,"\pi_{X}",swap,sloped] \ar[dr,"",sloped] \ar[d,,"{f}" description] & \ X & X\times \textbf{1}\ar[l,"\pi_{X}"] \ar[r,"",swap] & \textbf{1} \end{tikzcd} ] \begin{problem}[framed]{} Problem: & (e) There is another arrow $X \times 1 \rightarrow X \times 1$ so that the above diagram commutes. What is it? (Hint: it's a composition of two other arrows)

(f) Use the uniqueness property of products to conclude that the two arrows from parts (d) and (e) must be equal.

(g) Conclude that the arrow $u$ from part $(c)$ is a left-inverse to $\pi_{X}: X \times 1 \rightarrow X$ as well as a right inverse.

(h) Conclude that $u$ is an isomorphism, and $X \cong X \times 1$."\

Solution: & a) Domain and codomain of $\pi_X$ are $ X\times \textbf{1}$ and $X$ resp. Domain and codomain of $\pi_{\textbf{1}}$ are $ X\times \textbf{1}$ and $\textbf{1}$ resp.

b) Another object is $X$ and the arrows $X \to X$ is identity and $X \to \textbf{1}$ is the unique map corresponding to the terminal object.

c) If we replace $A$ by $X$ and $B$ by $\textbf{1}, \rho_A=id, \pi_A=\pi_X$ in the figure of definition 2, \end{problem} [ \begin{tikzcd}[row sep=huge] & X\ar[dl,"id",swap,sloped] \ar[dr,"\rho_{B}",sloped] \ar[d,dashed,"{u}" description] & \ X & X \times \textbf{1}\ar[l,"\pi_{X}"] \ar[r,"\pi_{\textbf{1}}",swap] & \textbf{1} \end{tikzcd} ]

\begin{problem}[framed]{} Solution: &we'll get the unique map from $u:X \to X \times \mathbf{1} $ s.t $\pi_X \circ u=id_X$. Hence we get the right-inverse $\pi_A$ of $u$. Observe that $u: X \to X \times \mathbf{1}$ is the inclusion map here i.e. $u(x)={x}\times \mathbf{1}.$

d) %We can see that $u \circ \pi_X({x} \times \mathbf{1})=u(x)={x} \times \mathbf{1}$, i.e., $$X \times \mathbf{1} \stackrel{\pi_X}{\longrightarrow} X \stackrel{u}{\longrightarrow} X \times \mathbf{1} %$$ is the identity map. Hence $u$ is also a left-inverse of $\pi_X$. We name $f=id_{X \times \mathbf{1}}.$

e) $u \circ \pi_X$ is another arrow $X \times 1 \rightarrow X \times 1$ so that $\pi_x \circ (u \circ \pi_X)=(\pi_x \circ u) \circ \pi_X=(id) \circ \pi_X=\pi_X$ hence, the above diagram commutes.

f) From Universal property of product we get $u \circ \pi_X=id_{X \times \mathbf{1}}.$

g) $u$ is a left inverse of $\pi_X.$

h) $X \cong X \times \mathbf{1}.$ \end{problem}

\end{document}

See qn 2 and then qn 5. You will realize what is looking odd here. I have to break the frame every time I want to include a diagram.

Ri-Li
  • 113
  • 5

1 Answers1

1

Your code produces multiple errors when I run it through TeXLive 2022. This is because you apparently pasted the same code for environ and subproof twice. I'll remove that for you.

Either way, you need to use the ampersand replacement option since Environ environments will grab the body of the environemt and at that point TikZ has no chance to change the catcode for & (it's a fake alignment in that way) anymore.

Usually using \& is fine (because the & character isn't used much in matrices):

\begin{tikzcd}[row sep=huge, ampersand replacement=\&]
      \& X \ar[dl,"id",swap,sloped] \ar[dr,"\rho_{B}",sloped] \ar[d,dashed,"{u}" description] \\
    X \& X \times \textbf{1}\ar[l,"\pi_{X}"] \ar[r,"\pi_{\textbf{1}}",swap] \& \textbf{1}
\end{tikzcd}

However, since all TikZ-CD diagrams – and in fact all TikZ matrices – inside a problem will need this I'd suggest adding

\tikzset{ampersand replacement=\&}

to the problem environment.
You will still need to use \& instead of & in the diagrams but you don't have to specify ampersand replacement=\& anymore.

Neither \[\] nor the equation* environment from amsmath can handle display-math content in your tabularx very well which is why I'm using the center environment here to center the diagrams. (TikZ-CD makes sure the content is in math-mode anyway so there's no technical reason to use a math environment here anyway – unless you want equation numbering.)


  • Don't use (a), (b), etc. manually to label, I've added \enumalphparen so that the enumerate environment can be used inside problem which labels the \items (a), (b), ….

    \newcommand*\enumalphparen{%
      \renewcommand*\labelenumi{\theenumi}%
      \renewcommand*\theenumi{(\alph{enumi})}}%
    

    Using the enumerate environment also allows you to use the \label-\ref system conveniently.

  • Don't use \textbf for math content in math mode. Use \mathbf instead.

  • Don't use \mathbf. Use logical syntax. I've defined

     \newcommand*\obj[1]{\mathbf{#1}}
    

    so that you can do \obj{1} without having to think about how Objects are typeset.

  • The enumerate in the solution part has no paragraph beforehand. Use \vspace{-\topskip} to pull the first item on the same height.

Code

\documentclass{amsart}
\usepackage{latexsym,amsmath}
\usepackage{tabularx, environ}
\usepackage{wasysym,latexsym,amsmath,amssymb,mathrsfs}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{mathtools}
\newcommand{\one}{\obj{1}}

\usepackage{scalerel,stackengine} \usepackage{tikz-cd} \usepackage{pst-node} \DeclareMathOperator{\id}{id} \stackMath \newcommand\reallywidehat[1]{% \savestack{\tmpbox}{\stretchto{% \scaleto{% \scalerel*[\widthof{\ensuremath{#1}}]{\kern-.6pt\bigwedge\kern-.6pt}% {\rule[-\textheight/2]{1ex}{\textheight}}%WIDTH-LIMITED BIG WEDGE }{\textheight}% }{0.5ex}}% \stackon[1pt]{#1}{\tmpbox}% } \parskip 1ex

\newtheorem{theorem}{Theorem} \newtheorem{corollary}{Corollary}[theorem] \newtheorem{lemma}[theorem]{Lemma} \newtheorem{definition}{Definition}[theorem] \newtheorem{remark}{Remark}[theorem] \newtheorem{question}{Question}[theorem] \newtheorem{solution}{Solution}[theorem] \makeatletter

% https://tex.stackexchange.com/a/199244/26355 \newcolumntype{\expand}{} \long@namedef{NC@rewrite@\string\expand}{\expandafter\NC@find} \NewEnviron{problem}[2][]{% \tikzset{ampersand replacement=&}% ← added !! \enumalphparen % ← added !! \def\problem@arg{#1}% \def\problem@framed{framed}% \def\problem@lined{lined}% \def\problem@doublelined{doublelined}% \ifx\problem@arg@empty% \def\problem@hline{}% \else% \ifx\problem@arg\problem@doublelined% \def\problem@hline{\hline\hline}% \else% \def\problem@hline{\hline}% \fi% \fi% \ifx\problem@arg\problem@framed% \def\problem@tablelayout{|>{\bfseries}lX|c}% \def\problem@title{\multicolumn{2}{|l|}{% \raisebox{-\fboxsep}{\textsc{\Large #2}}% }}% \else \def\problem@tablelayout{>{\bfseries}lXc}% \def\problem@title{\multicolumn{2}{l}{% \raisebox{-\fboxsep}{\textsc{\Large #2}}% }}% \fi% \bigskip\par\noindent% \renewcommand{\arraystretch}{1.2}% \begin{tabularx}{\textwidth}{\expand\problem@tablelayout}% \problem@hline% \problem@title\[2\fboxsep]% \BODY\\problem@hline% \end{tabularx}% \medskip\par% } \makeatother \newenvironment{subproof}[1][\proofname]{% \renewcommand{\qedsymbol}{$\blacksquare$}% \begin{proof}[#1]% }{% \end{proof}% } \usepackage{tikz-cd} %%% Added: \newcommand\enumalphparen{% \renewcommand\labelenumi{\theenumi}% \renewcommand\theenumi{(\alph{enumi})}}% \newcommand\obj[1]{\mathbf{#1}} %%%

\begin{document} \begin{problem}[framed]{Question 2} %Task: & Define a new ``problem'' environment. \ Problem: & Show that any two terminal objects are isomorphic. Specifically, if $\obj{1}$ and $\obj{1}^{\prime}$ are both terminal objects, show that there are arrows $f: \obj{1} \rightarrow \obj{1}^{\prime}$ and $g: \obj{1}^{\prime} \rightarrow \obj{1}$ such that $g \circ f=\mathrm{id}{1}$ and $f \circ g=\mathrm{id}{1}$. This is what it means for two objects to be isomorphic in a category.\ Solution: & As, $\obj{1},\obj{1}^{\prime}$ are terminal objects. From $\obj{1} \to \obj{1}^{\prime}, \obj{1} \to \obj{1}$ we have a unique map so are from $\obj{1}^{\prime} \to \obj{1}, \obj{1}^{\prime}\to \obj{1}^{\prime}$. Then we have maps $f \circ g: \obj{1}^{\prime} \to \obj{1}^{\prime}$ and $g \circ f: \obj{1} \to \obj{1}.$ Now $id|{\obj{1}^{\prime}}:\obj{1}^{\prime} \to \obj{1}^{\prime}$ and $id|{\obj{1}}:\obj{1} \to \obj{1}$ are also maps then $g \circ f=id_{\obj{1}}$ and $f \circ g=id_{\obj{1}^{\prime}}.$ \end{problem}

\begin{problem}[framed]{Question 5} %Task: & Define a new ``problem'' environment. \ Problem: & Let $\obj{C}$ be a category with terminal object $\obj{1}$. Let $X$ be an object of $\obj{C}$. We will prove that $X \times 1$ is isomorphic to $X$. \begin{enumerate} \item Because $X \times 1$ is the product of $X$ and 1, it comes with two arrows. Describe them by stating their domain and codomains. \item There is another object with arrows to both $X$ and 1. What is it? What are the arrows? \item Use the existence property of products to find a right-inverse $u$ for the arrow $\pi_{X}: X \times \obj{1} \rightarrow X$. \label{item:c} \item Now we want to show that $u$ is a left-inverse to $\pi_{X}$ as well. To that end, name one arrow $f: X \times \obj{1} \rightarrow X \times \obj{1}$ so that the following diagram commutes, meaning that $\pi_{X} \circ f=\pi_{X}$. \label{item:d} \begin{center} \begin{tikzcd}[row sep=huge] & X\times \obj{1} \ar[dl,"\pi_X", swap, sloped] \ar[dr] \ar[d,"f" description] \ X & X\times \obj{1} \ar[l,"\pi_X"] \ar[r,"",swap] & \obj{1} \end{tikzcd} \end{center} \item There is another arrow $X \times 1 \rightarrow X \times 1$ so that the above diagram commutes. What is it? (Hint: it's a composition of two other arrows.) \label{item:e} \item Use the uniqueness property of products to conclude that the two arrows from items \ref{item:d} and \ref{item:e} must be equal. \item Conclude that the arrow $u$ from part \ref{item:c} is a left-inverse to $\pi_{X}: X \times 1 \rightarrow X$ as well as a right inverse. \item Conclude that $u$ is an isomorphism, and $X \cong X \times 1$. \end{enumerate}\ %%%%% Solution: & \vspace{-\topskip} % no text here, remove topskip spacing from enumerate \begin{enumerate} \item Domain and codomain of $\pi_X$ are $ X\times \obj{1}$ and $X$ resp. Domain and codomain of $\pi_{\obj{1}}$ are $ X\times \obj{1}$ and $\obj{1}$ resp. \item Another object is $X$ and the arrows $X \to X$ is identity and $X \to \obj{1}$ is the unique map corresponding to the terminal object. \item If we replace $A$ by $X$ and $B$ by $\obj{1}, \rho_A=id, \pi_A=\pi_X$ in the figure of definition 2, \begin{center} \begin{tikzcd}[row sep=huge] & X \ar[dl, "id", swap, sloped] \ar[dr, "\rho_{B}", sloped] \ar[d, dashed, "u" description] \ X & X \times \obj{1} \ar[l, "\pi_X"] \ar[r, "\pi_{\obj{1}}", swap] & \obj{1} \end{tikzcd} \end{center} we'll get the unique map from $u:X \to X \times \obj{1}$ s.,t. $\pi_X \circ u=id_X$. Hence we get the right-inverse $\pi_A$ of $u$. Observe that $u: X \to X \times \obj{1}$ is the inclusion map here i.,e. $u(x)={x}\times \obj{1}.$ \item %We can see that $u \circ \pi_X({x} \times \obj{1})=u(x)={x} \times \obj{1}$, i.e., $$X \times \obj{1} \stackrel{\pi_X}{\longrightarrow} X \stackrel{u}{\longrightarrow} X \times \obj{1} %$$ is the identity map. Hence $u$ is also a left-inverse of $\pi_X$. We name $f=id_{X \times \obj{1}}.$ \item $u \circ \pi_X$ is another arrow $X \times 1 \rightarrow X \times 1$ so that $\pi_x \circ (u \circ \pi_X)=(\pi_x \circ u) \circ \pi_X=(id) \circ \pi_X=\pi_X$ hence, the above diagram commutes. \item From Universal property of product we get $u \circ \pi_X=id_{X \times \obj{1}}.$ \item $u$ is a left inverse of $\pi_X.$ \item $X \cong X \times \obj{1}.$ \end{enumerate} \end{problem}

\end{document}

Output

enter image description here

Qrrbrbirlbel
  • 119,821