![表格中的自动对齐](https://linux22.com/image/257786/%E8%A1%A8%E6%A0%BC%E4%B8%AD%E7%9A%84%E8%87%AA%E5%8A%A8%E5%AF%B9%E9%BD%90.png)
我正在尝试制作一个同时具有左对齐和右对齐的表格。现在我可以获得如下视图
第一个问题是左对齐 - 左侧和包含两个项目的表格之间有一个空格。
第二个问题是我必须手动设置 parboxes 的宽度。难道不是通过标题的宽度来自动完成这一操作吗?也许 parboxes 不是表格中换行的最佳方式?
我的代码:
\documentclass{article}
\usepackage{multicol}
\usepackage{makecell}
\usepackage{pbox}
\usepackage{array}
\usepackage{amsmath}
\begin{document}
\begin{tabular}{l}
{\Huge Some title text is written here...} \\
\Xhline{1.5mm}
\parbox{11.1cm}{
\begin{multicols}{2}
\renewcommand{\arraystretch}{2}
\begin{tabular}{|c|c|}
\hline
$\boldsymbol{\bigotimes}$ & {\large this is an example} \\
\hline
\end{tabular} \\
Lorem ipsum dolor sit amet, consectetur adipisicing elit
\end{multicols}
} \\
\renewcommand{\arraystretch}{2}
\begin{tabular}{|c|cll|}
\hline
$\bigcirc$ & 1 & First item &
\pbox{7.3cm}{Sed ut perspiciatis unde
omnis iste natus error sit voluptatem
accusantium doloremque laudantium} \\
\hline
$\bigcirc$ & 2 & Second item & Some definition. \\
\hline
\end{tabular}
\end{tabular}
\end{document}
答案1
多个嵌套的表格和 parbox 使输入变得复杂,我认为您可以使用更简单的方案,如下所示:
\documentclass{article}
\usepackage{tabularx}
\usepackage{amsmath}
\setlength\extrarowheight{3pt}
\begin{document}
\noindent
{\Huge \strut Some title text is written here...\par}
\hrule height 3pt
\smallskip
\noindent
\begin{tabularx}{\textwidth}{|l|l|X}
\cline{1-2}
$\boldsymbol{\bigotimes}$ &
\large this is an example &
Lorem ipsum dolor sit amet, consectetur adipisicing elit\\
\cline{1-2}
\end{tabularx}
\smallskip
\noindent
\begin{tabularx}{\textwidth}{|l|llX|}
\hline
$\bigcirc$ & 1 & First item &
Sed ut perspiciatis unde
omnis iste natus error sit voluptatem
accusantium doloremque laudantium \\
\hline
$\bigcirc$ & 2 & Second item & Some definition. \\
\hline
\end{tabularx}
\end{document}