我怎样才能让tabularx
里面的第 6 个问题均匀地分成 2 个,而不超出边界?
(我目前使用的p{0.25cm}p{7cm}
不是最佳的,因为我需要手动指定宽度)
子问题(不太重要):
如何将问题 5 中的 (a) 和 (b) 与问题 6 中的 (a) 对齐?
如何缩进问题 6 中的 i.、ii. 和 iii.,使其与 (a) 和 (b) 不对齐?
请注意,下面的示例可以工作,但样式和格式不是最佳的(我还收到了 2Underfull \hbox
和 7 条Overfull \hbox
消息)。
另请注意,我对 LaTeX 排版非常陌生(昨天才安装!),如果对代码的整体样式有任何反馈,我将不胜感激
\documentclass[12pt]{article}
% Set page margin to 1 inch on all sides
\usepackage[margin=1in]{geometry}
% Required for custom enumeration styles
\usepackage{enumerate}
\usepackage{multicol}
\usepackage{tabularx}
% Increase line height for table
\setlength{\extrarowheight}{10pt}
\begin{document}
\begin{center}
\begin{Large}My Title\end{Large}\\
\end{center}
\begin{enumerate}
\setcounter{enumi}{4}
\item
The cumulative frequency graph below represents the height (in meters) of 100 people living in London. (Graph omitted)
\begin{enumerate}[(a)]
\item
Estimate
\begin{multicols}{2}
\begin{enumerate}[i.]
\item the median height
\item the 75\textsuperscript{th} percentile of the height
\end{enumerate}
\end{multicols}
\item \ldots
\end{enumerate}
\item
Sketch the solid whose region is given by the integral:
\begin{tabularx}{\textwidth}{X|X}
(a) $\int_0^2 \int_0^3 \int_0^4 dz\ dx\ dy$ & (b) $\int_0^3 \int_{x^2}^{9} \int_0^{e^{5^2}} dz\ dy\ dx$\\
Rewrite the above integral using the orders: & Rewrite the above integral using the orders:\\
{
\begin{tabularx}{\textwidth}{p{0.25cm}p{7cm}}
i. & $dx\,dy\,dz$\\
ii. & $dy\,dx\,dz$\\
iii. & Evaluate each of the above 3 integrals using your calculator
\end{tabularx}
}
&
{
\begin{tabularx}{\textwidth}{p{0.25cm}p{7cm}}
i. & $dy\,dz\,dx$\\
ii. & $dx\,dy\,dz$\\
iii. & Evaluate each of the above 3 integrals using your calculator
\end{tabularx}
}\\
\end{tabularx}
\end{enumerate}
\end{document}
答案1
两种解决方法:
1)全部自动,无表,如果两侧的multicols
高度不同,则可以使用\columnbreak
,如我的MWE的第7点和第8点所述:
\documentclass[12pt]{article}
% Set page margin to 1 inch on all sides
\usepackage[margin=1in]{geometry}
% Required for custom enumeration styles
\usepackage{enumerate}
\usepackage{multicol}
\usepackage{tabularx}
% Increase line height for table
\setlength{\extrarowheight}{10pt}
\begin{document}
\begin{center}
\begin{Large}My Title\end{Large}\\
\end{center}
\begin{enumerate}
\setcounter{enumi}{4}
\item
The cumulative frequency graph below represents the height (in meters) of 100 people living in London. (Graph omitted)
\begin{enumerate}[(a)]
\item
Estimate
\begin{multicols}{2}
\begin{enumerate}[i.]
\item the median height
\item the 75\textsuperscript{th} percentile of the height
\end{enumerate}
\end{multicols}
\item \ldots
\end{enumerate}
\item
Sketch the solid whose region is given by the integral:
\begin{multicols}{2}\setlength{\columnseprule}{0.4pt}
\begin{enumerate}[(a)]
\item $\int_0^2 \int_0^3 \int_0^4 dz\ dx\ dy$
Rewrite the above integral using the orders:
\begin{enumerate}[i.]
\item $dx\,dy\,dz$
\item $dy\,dx\,dz$
\item Evaluate each of the above 3 integrals using your calculator
\end{enumerate}
\item $\int_0^3 \int_{x^2}^{9} \int_0^{e^{5^2}} dz\ dy\ dx$
Rewrite the above integral using the orders:
\begin{enumerate}[i.]
\item $dy\,dz\,dx$
\item $dx\,dy\,dz$
\item Evaluate each of the above 3 integrals using your calculator
\end{enumerate}
\end{enumerate}
\end{multicols}
\item
In case the first column is longer than the second one:
\begin{multicols}{2}\setlength{\columnseprule}{0.4pt}
\begin{enumerate}[(a)]
\item in this case the first column has a text longer than the second one
\columnbreak
\item blah
\end{enumerate}
\end{multicols}
\item
In case the second column is longer than the first one:
\begin{multicols}{2}\setlength{\columnseprule}{0.4pt}
\begin{enumerate}[(a)]
\item blah blah blah
\columnbreak
\item in this case the second column has a text longer than the first one
\end{enumerate}
\end{multicols}
\end{enumerate}
\end{document}
2)带有定制柜台和桌子:
\documentclass[12pt]{article}
% Set page margin to 1 inch on all sides
\usepackage[margin=1in]{geometry}
% Required for custom enumeration styles
\usepackage{enumerate}
\usepackage{multicol}
\usepackage{tabularx}
% Increase line height for table
\setlength{\extrarowheight}{10pt}
\newcounter{itemalpha}
\newcounter{itemroman}
\newcommand*{\itemalpha}{\stepcounter{itemalpha}(\alph{itemalpha})}
\newcommand*{\resetitemalpha}{\setcounter{itemalpha}{0}}
\newcommand*{\itemroman}{\stepcounter{itemroman}\roman{itemroman}.}
\newcommand*{\resetitemroman}{\setcounter{itemroman}{0}}
\begin{document}
\begin{center}
\begin{Large}My Title\end{Large}\\
\end{center}
\begin{enumerate}
\setcounter{enumi}{4}
\item
The cumulative frequency graph below represents the height (in meters) of 100 people living in London. (Graph omitted)
\begin{enumerate}[(a)]
\item
Estimate
\begin{multicols}{2}
\begin{enumerate}[i.]
\item the median height
\item the 75\textsuperscript{th} percentile of the height
\end{enumerate}
\end{multicols}
\item \ldots
\end{enumerate}
\item
Sketch the solid whose region is given by the integral:
\begin{tabular}{@{}r@{\hspace{\labelsep}}p{.41\textwidth}|r@{\hspace{\labelsep}}p{.41\textwidth}@{}}
\itemalpha &$\int_0^2 \int_0^3 \int_0^4 dz\ dx\ dy$ & \itemalpha &$\int_0^3 \int_{x^2}^{9} \int_0^{e^{5^2}} dz\ dy\ dx$\\
&Rewrite the above integral using the orders: & & Rewrite the above integral using the orders:\\
&
{
\begin{tabular}{@{}r@{\hspace{\labelsep}}p{.37\textwidth}@{}}
\itemroman & $dx\,dy\,dz$\\
\itemroman & $dy\,dx\,dz$\\
\itemroman & Evaluate each of the above 3 integrals using your calculator
\end{tabular}
}
& &
{
\begin{tabular}{@{}r@{\hspace{\labelsep}}p{.37\textwidth}@{}}
\resetitemroman\itemroman & $dy\,dz\,dx$\\
\itemroman & $dx\,dy\,dz$\\
\itemroman & Evaluate each of the above 3 integrals using your calculator
\end{tabular}
}\\
\end{tabular}
\end{enumerate}
\end{document}
答案2
类似的解决方案,通过 中的中等大小命令进行了一些改进nccmath
,并调整了一些长度。主要区别在于,我没有将tabularx
s 嵌套在另一个 中tabularx
,而是将 嵌套在一个enumerate
(使用 定制的enumitem
)中,以便获得(可参考的)自动编号:
\documentclass[12pt]{article}
% Set page margin to 1 inch on all sides
\usepackage[margin=1in, showframe]{geometry}
% Required for custom enumeration styles
\usepackage[shortlabels]{enumitem}
\usepackage{multicol}
\usepackage{ragged2e}
\usepackage{tabularx}
\usepackage{nccmath}
\newcommand{\mint}{\medint\int}
% Increase line height for table
\setlength{\extrarowheight}{10pt}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\begin{document}
\begin{center}
\begin{Large}My Title\end{Large}\\
\end{center}
\begin{enumerate}
\setcounter{enumi}{4}
\item
The cumulative frequency graph below represents the height (in meters) of 100 people living in London. (Graph omitted)
\begin{enumerate}[(a)]
\item
Estimate
\begin{multicols}{2}
\begin{enumerate}[i., wide = 0pt]
\item the median height
\item the 75\textsuperscript{th} percentile of the height
\end{enumerate}
\end{multicols}
\item \ldots
\end{enumerate}
\item
Sketch the solid whose region is given by the integral:
\begin{tabularx}{\linewidth}{>{\compress}X|>{\compress}X}
(a) $\mint_0^2 \mint_0^3 \mint_0^4 dz\, dx\, dy$ & (b) $\mint_0^3 \mint_{x^2}^{9} \mint_0^{e^{5^2}} dz\, dy\, dx$\\
Rewrite the above integral using the orders: & Rewrite the above integral using the orders:\\[-1.5ex]
\begin{enumerate}[i., leftmargin = *, nosep]
\item $dx\,dy\,dz$
\item $dx\,dy\,dz$
\item Evaluate each of the above 3 integrals using your calculator
\end{enumerate}
&
\begin{enumerate}[i., leftmargin = *, nosep]
\item $dx\,dy\,dz$
\item $dx\,dy\,dz$
\item Evaluate each of the above 3 integrals using your calculator
\end{enumerate}
\\
\end{tabularx}
\end{enumerate}
\end{document}
答案3
您可以使用下面的代码,其中我已替换了p{7cm}
byX
列以及所有出现的\textwidth
by \linewidth
。
\documentclass[12pt]{article}
% Set page margin to 1 inch on all sides
\usepackage[margin=1in]{geometry}
% Required for custom enumeration styles
\usepackage{enumerate}
\usepackage{multicol}
\usepackage{tabularx}
% Increase line height for table
\setlength{\extrarowheight}{10pt}
\begin{document}
\begin{center}
\begin{Large}My Title\end{Large}\\
\end{center}
\begin{enumerate}
\setcounter{enumi}{4}
\item
The cumulative frequency graph below represents the height (in meters) of 100 people living in London. (Graph omitted)
\begin{enumerate}[(a)]
\item
Estimate
\begin{multicols}{2}
\begin{enumerate}[i.]
\item the median height
\item the 75\textsuperscript{th} percentile of the height
\end{enumerate}
\end{multicols}
\item \ldots
\end{enumerate}
\item
Sketch the solid whose region is given by the integral:
\begin{tabularx}{\linewidth}{X|X}
(a) $\int_0^2 \int_0^3 \int_0^4 dz\ dx\ dy$ & (b) $\int_0^3 \int_{x^2}^{9} \int_0^{e^{5^2}} dz\ dy\ dx$\\
Rewrite the above integral using the orders: & Rewrite the above integral using the orders:\\
{
\begin{tabularx}{\linewidth}{p{0.25cm}X}
i. & $dx\,dy\,dz$\\
ii. & $dy\,dx\,dz$\\
iii. & Evaluate each of the above 3 integrals using your calculator
\end{tabularx}
}
&
{
\begin{tabularx}{\linewidth}{p{0.25cm}X}
i. & $dy\,dz\,dx$\\
ii. & $dx\,dy\,dz$\\
iii. & Evaluate each of the above 3 integrals using your calculator
\end{tabularx}
}\\
\end{tabularx}
\end{enumerate}
\end{document}
或者,您可以使用类似下面的解决方案。我已将内部tabularx
环境替换为enumerate
环境。为了正确设置它,我还用enumerate
更强大的enumitem
包替换了包。
\documentclass[12pt]{article}
% Set page margin to 1 inch on all sides
\usepackage[margin=1in]{geometry}
% Required for custom enumeration styles
\usepackage{enumitem}
\usepackage{multicol}
\usepackage{tabularx}
% Increase line height for table
\setlength{\extrarowheight}{10pt}
\begin{document}
\begin{center}
\begin{Large}My Title\end{Large}\\
\end{center}
\begin{enumerate}
\setcounter{enumi}{4}
\item
The cumulative frequency graph below represents the height (in meters) of 100 people living in London. (Graph omitted)
\begin{enumerate}[label=({\alph*})]
\item Estimate
\begin{multicols}{2}
\begin{enumerate}[label={\roman*}.]
\item the median height
\item the 75\textsuperscript{th} percentile of the height
\end{enumerate}
\end{multicols}
\item \ldots
\end{enumerate}
\item
Sketch the solid whose region is given by the integral:
\begin{tabularx}{\linewidth}{X|X}
(a) $\int_0^2 \int_0^3 \int_0^4 dz\ dx\ dy$ & (b) $\int_0^3 \int_{x^2}^{9} \int_0^{e^{5^2}} dz\ dy\ dx$\\
Rewrite the above integral using the orders: & Rewrite the above integral using the orders:\\
\begin{minipage}[t]{\linewidth}
\begin{enumerate}[label={\roman*}.,align=left]
\item $dx\,dy\,dz$
\item $dy\,dx\,dz$
\item Evaluate each of the above 3 integrals using your calculator
\end{enumerate}
\end{minipage}&
\begin{minipage}[t]{\linewidth}
\begin{enumerate}[label={\roman*}.,align=left]
\item $dx\,dy\,dz$
\item $dy\,dx\,dz$
\item Evaluate each of the above 3 integrals using your calculator
\end{enumerate}
\end{minipage}
\end{tabularx}
\end{enumerate}
\end{document}
要缩进 i.、ii. ...,您可以将选项添加leftmargin=1.75cm
到相应的\begin{enumerate}[label={\roman*}.,align=left]
行。
下图比较了上述两个 MWE 的输出。左侧:枚举方法,右侧:嵌套表格,黑线是由包引起的showframe
,我已将其包括在内以可视化边距)