将交换图纳入问答框架的问题

将交换图纳入问答框架的问题

我无法将交换图放在框架下:

\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}

参见问题 2 和问题 5。您会意识到这里看起来很奇怪。每次我想添加图表时,我都必须打破框架。

答案1

当我通过 TeXLive 2022 运行您的代码时,它会产生多个错误。这是因为您显然将相同的代码粘贴了environ两次subproof。我会帮您删除它。

无论哪种方式,您都需要使用ampersand replacement选项因为Environ环境将抓住环境的主体,此时 TikZ 没有机会再改变 catcode &(在这种情况下它是一种假对齐)。

通常使用\&就可以了(因为该&字符在矩阵中不怎么使用):

\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}

但是,由于所有 TikZ-CD 图(实际上是所有 TikZ 矩阵)都problem需要这个,我建议添加

\tikzset{ampersand replacement=\&}

problem环境中。
您仍然需要在图表中使用\&而不是,&但您不必再指定ampersand replacement=\&

无论是环境\[\]还是示例都无法很好地处理显示数学内容,这就是我在这里使用环境来使图表居中的原因。(TikZ-CD 确保内容无论如何都处于数学模式,因此无论如何都没有技术理由在这里使用数学环境 - 除非您想要方程编号。)equation*amsmathtabularxcenter


  • 不要手动使用(a)(b)等来标记,我已经添加了,\enumalphparen以便enumerate在环境内部可以使用problem标记\items (a)、、(b)...

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

    使用该enumerate环境还可以让您方便地使用\label-\ref系统。

  • 不要\textbf在数学模式中用于数学内容。请\mathbf改用。

  • 不要使用\mathbf。使用逻辑语法。我已经定义了

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

    这样你就不必\obj{1}考虑对象是如何排版的了。

  • 解决方案部分中的前面enumerate没有段落。使用\vspace{-\topskip}将第一项拉到同一高度。

代码

\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}

输出

在此处输入图片描述

相关内容