我使用了以下命令:
\documentclass{article}
\usepackage{xypic}
\usepackage[final]{showexpl}
\begin{document}
\begin{LTXexample}[pos=r,rframe=single,numbers=none,basicstyle=\ttfamily\small,]
\xymatrix{A \ar[r]^f & B}
\xymatrix{A \ar@{^{(}->}[r]^f & B}
\end{LTXexample}
\end{document}
这让我
但我更愿意创建下表:
答案1
您可以使用一个简单的tabular
环境:
\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage{array}
\usepackage{xypic}
\begin{document}
\begin{center}
\renewcommand\arraystretch{1.25}
\begin{tabular}{|p{.6\linewidth}|>{\centering\arraybackslash}p{.3\linewidth}|}
\hline
\centering Objetive {\footnotesize and} Input \par\footnotesize Commands to produce the diagrams displayed on the right are as follows, respectively: &
Output\par\footnotesize\itshape (what you get)
\tabularnewline\hline
{\small The default case arrow:}\par
\verb+\xymatrix{A \ar[r]^f & B}+ & $\xymatrix{A \ar[r]^f & B}$
\tabularnewline\hline
{\small Inclusion arrow:}\par
\verb+\xymatrix{A \ar@{^{(}->}[r]^f & B}+ & $\xymatrix{A \ar@{^{(}->}[r]^f & B}$
\tabularnewline\hline
\end{tabular}
\end{center}
\end{document}
答案2
这避免了代码重复;您在左列中指定代码,并\usecode
在第二列中说。
\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage{array,booktabs,xparse}
\usepackage{xypic}
\NewDocumentCommand{\code}{v}{%
\gdef\usecode{$\scantokens{#1}$}%
\texttt{#1}}
\begin{document}
\begin{table}
\caption{Table of the main \Xy{} constructs}
\centering
\bigskip
\begin{tabular}{
m{.6\columnwidth}
>{\centering\arraybackslash} m{.3\columnwidth}
}
\toprule
\multicolumn{1}{p{.6\columnwidth}}{\centering
Objective {\footnotesize and} Input \par
\footnotesize Commands to produce the diagrams displayed
on the right are as follows, respectively:} &
\multicolumn{1}{p{.3\columnwidth}}{\centering
Output\par\footnotesize\itshape (what you get)} \\
\midrule
The default case arrow:\newline
\code{\xymatrix{A \ar[r]^f & B}} & \usecode \\
\midrule
Inclusion arrow:\newline
\code{\xymatrix{A \ar@{^{(}->}[r]^f & B}} & \usecode \\
\bottomrule
\end{tabular}
\end{table}
\end{document}