在 colorbox 中使用 tikzcd 包

在 colorbox 中使用 tikzcd 包

我正在嘗試使用 tikzcd 包在彩盒內製作交換圖。儘管程式碼在 colorbox 環境之外工作,但我在組合這兩個環境時遇到了麻煩。任何幫助將非常感激!下面是我的程式碼:

     % Colored Boxed Definition
     \newenvironment{colbox}[3]{       
       \begin{center}                   % Centering minipage
       \colorbox[HTML]{#1} {            % Set's the color of minipage
       \begin{minipage}[b]{380px}       % Starts minipage
      \textbf{#2}\\ \textit{#3}       
     \end{minipage}}                     % End minipage
     }{\end{center}}                    

 \begin{document}

\begin{center}
    \colorbox[HTML]{F8E0E0}{
     \begin{minipage}[c]{450px}
      \textbf{Definition 1.1}\\ 
Let $V^1, \ V^2, \ \ldots , \ V^d, \ T$ be vectors spaces over K and let $\otimes$ be the multilinear mapping   
\begin{align*} 
 &\quad  \otimes\\
V^1 \times V^2 \times \ldots \times V^d \ &\longrightarrow \quad T\\\
\end{align*} 
such that T equals the space spanned by the image of $\otimes$, and for any multilinear mapping 
\begin{align*} 
 &\quad  f\\
V^1 \times V^2 \times \ldots \times V^d \ &\longrightarrow \quad H\\\
\end{align*} 
for any vector space H, there exists a unique linear mapping
\begin{align*} 
 &\quad  F\\
T \ &\longrightarrow \quad H\\\
\end{align*} 
which makes the following diagram commute
\begin{tikzcd}
V^1 \times V^2 \times \ldots \times V^d \arrow [r, "\otimes"]
                                     \arrow [dr, swap, "f \text{ multilinear}"]
&
T \arrow [densely dotted, d, "\exists 1 \ F \text{ linear}"]
\\
&
H
\end{tikzcd}
T is called the $\textbf{d-fold tensor product of $V^1 \times V^2 \times \ldots \times V^d$}$ and is denoted ${V^1 \otimes V^2 \otimes \ldots \otimes V^d}$, and its elements are called \textbf{tensors}. $\otimes({v^1 \times v^2 \times \ldots \times v^d})$ is denoted ${v^1 \otimes v^2 \otimes \ldots \otimes v^d}$. The tensors in the image of $\otimes$ are called $\textbf{simple tensors}$. 
     \end{minipage}}
\end{center}

\end{document}

答案1

問題是,當tikzcd在另一個命令的參數內時,您需要使用ampersand-replacement.

colbox如果您正確定義您的環境,那就更好了。

\documentclass{article}
\usepackage{amsmath,xcolor,tikz-cd}

% Colored Boxed Definition
\newenvironment{colbox}[3][380pt]{%
  \renewcommand{\colboxcolor}{#2}%
  \begin{lrbox}{\colboxbox}
  \begin{minipage}[b]{#1}
  \textbf{#3}\\ \itshape
}{%
  \end{minipage}
  \end{lrbox}%
  \begin{center}
  \colorbox[HTML]{\colboxcolor}{\usebox{\colboxbox}}
  \end{center}
}
\newsavebox{\colboxbox}
\newcommand{\colboxcolor}

\begin{document}

\begin{colbox}[\dimexpr\textwidth-2\fboxsep]{F8E0E0}{\textbf{Definition 1.1}}
Let $V^1$, $V^2$, \dots, $V^d$, $T$ be vector spaces over $K$ and let 
$\otimes$ be the multilinear mapping   
\begin{equation*} 
V^1 \times V^2 \times \dots \times V^d \xrightarrow{\otimes} T
\end{equation*} 
such that $T$ equals the space spanned by the image of $\otimes$, and 
for any multilinear mapping 
\begin{equation*} 
V^1 \times V^2 \times \dots \times V^d \xrightarrow{f} H
\end{equation*} 
for any vector space $H$, there exists a unique linear mapping
\begin{equation*} 
T \xrightarrow{F} H
\end{equation*} 
which makes the following diagram commute
\[
\begin{tikzcd}
V^1 \times V^2 \times \dots \times V^d \arrow [r, "\otimes"]
                                     \arrow [dr, swap, "f \text{ multilinear}"]
&
T \arrow [densely dotted, d, "\exists 1 \ F \text{ linear}"]
\\
&
H
\end{tikzcd}
\]
$T$ is called the \textbf{d-fold tensor product of 
$V^1 \times V^2 \times \dots \times V^d$} and is denoted 
${V^1 \otimes V^2 \otimes \dots \otimes V^d}$, and its elements 
are called \textbf{tensors}. 
$\otimes({v^1 \times v^2 \times \dots \times v^d})$ is denoted 
${v^1 \otimes v^2 \otimes \dots \otimes v^d}$. The tensors in the 
image of $\otimes$ are called $\textbf{simple tensors}$. 
\end{colbox}

\end{document}

在此輸入影像描述

請注意我對程式碼所做的更改,特別是箭頭上的標籤。

我建議不要px作為一個單位使用。它的值不是固定的,與設備解析度無關。

相關內容