在 tabularx 环境中并排放置电路图

在 tabularx 环境中并排放置电路图

我的 MWE,

\documentclass[a4paper,11pt]{book}
\usepackage{tabularx}
\usepackage{tikz}

\begin{document}
\begin{enumerate}

\newcommand{\OOO}[4]{%
\begin{tabularx}{\linewidth}{@{}X@{}l@{}}
\textbf{A)} #1 & \textbf{B)} #2 \\
\textbf{C)} #3 & \textbf{D)} #4 \\
\end{tabularx}}

{\item  Convert the current source into an equivalent voltage source\\
\OOO{\input{./ABC/SZ-1a.tex}}
{\input{./ABC/SZ-1b.tex}}
{\input{./ABC/SZ-1c.tex}}
{\input{./ABC/SZ-1d.tex}}}

\end{enumerate}
\end{document}

并显示

在此处输入图片描述

{\item Convert the current source into an equivalent voltage source...\\
\begin{tabular}{ll}
\textbf{A)} & \textbf{B)}\\
\input{./ABC/SZ-1a.tex}&\input{./ABC/SZ-1a.tex}\\
\multicolumn{2}{l}{} \\
\textbf{C)} & \textbf{D)}\\
\input{./ABC/SZ-1c.tex}&\input{./ABC/SZ-1d.tex}
\end{tabular}}

并显示

在此处输入图片描述

相关:表格自动右对齐-多项选择题

怎么降档了?有解决办法吗?

答案1

tabularx如果我理解正确的话,对于或解决方案没有特殊要求tabular

\OOO可以通过四个小页面来制作。我提供了另一种方法,使用tcolorbox及其raster库来设置这四个部分:

\documentclass[a4paper,11pt]{book}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage[skins,raster]{tcolorbox}

\begin{document}
\begin{enumerate}

\newcommand{\OOO}[4]{%
\begin{tcbitemize}[blanker,fonttitle=\bfseries,coltitle=black,
    raster valign=top,raster row skip=2mm,raster column skip=4mm]
  \tcbitem[title=A)] #1
  \tcbitem[title=B)] #2
  \tcbitem[title=C)] #3
  \tcbitem[title=D)] #4
\end{tcbitemize}}

\item Convert the current source into an equivalent voltage source
  \OOO{\includegraphics[width=\linewidth]{example-image-a}}
      {\small\lipsum[2]}
      {\small\lipsum[3]}
      {\includegraphics[width=\linewidth]{example-image-b}}

\end{enumerate}
\end{document}

在此处输入图片描述

上述代码可生成顶部对齐的部分或单元格。以下变体可生成居中对齐的单元格:

\documentclass[a4paper,11pt]{book}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage[skins,raster]{tcolorbox}

\begin{document}
\begin{enumerate}

\newcommand{\OOO}[4]{%
\begin{tcbitemize}[blanker,fonttitle=\bfseries,coltitle=black,valign=center,
    raster equal height=rows,
    raster row skip=2mm,raster column skip=4mm]
  \tcbitem[title=A)] #1
  \tcbitem[title=B)] #2
  \tcbitem[title=C)] #3
  \tcbitem[title=D)] #4
\end{tcbitemize}}

\item Convert the current source into an equivalent voltage source
  \OOO{\includegraphics[width=\linewidth]{example-image-a}}
      {\small\lipsum[2]}
      {\small\lipsum[3]}
      {\includegraphics[width=\linewidth]{example-image-b}}

\end{enumerate}
\end{document}

在此处输入图片描述

最后,还有另一种变体,它构成了四个部分:

\documentclass[a4paper,11pt]{book}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage[skins,raster]{tcolorbox}

\begin{document}
\begin{enumerate}

\newcommand{\OOO}[4]{%
\begin{tcbitemize}[enhanced,size=small,sharp corners,colback=white,
    colframe=black!20,colbacktitle=blue!10,
    fonttitle=\bfseries,coltitle=black,valign=center,
    raster equal height=rows,raster row skip=1mm,raster column skip=1mm]
  \tcbitem[title=A)] #1
  \tcbitem[title=B)] #2
  \tcbitem[title=C)] #3
  \tcbitem[title=D)] #4
\end{tcbitemize}}

\item Convert the current source into an equivalent voltage source
  \OOO{\includegraphics[width=\linewidth]{example-image-a}}
      {\small\lipsum[2]}
      {\small\lipsum[3]}
      {\includegraphics[width=\linewidth]{example-image-b}}

\end{enumerate}
\end{document}

在此处输入图片描述

相关内容