使用 \multicolumn 的复杂表格

使用 \multicolumn 的复杂表格

我需要在Latex里面实现的布局是这样的(用M.word制作)在此处输入图片描述

我试图制作这种布局这是我的代码:

\begin{tabular}{ |p{2cm}||p{12cm}| }
\hline
\multicolumn{2}{|c|}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ligula ligula, tristique vel consectetur et, cursus eget ante. Sed sed vulputate magna, nec imperdiet sapien. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam faucibus pellentesque rhoncus. Aenean rhoncus, nibh vitae vestibulum pharetra, quam elit aliquam tellus, ut ultricies lacus purus nec felis. Cras in convallis risus, ac consectetur nulla. Proin enim justo, volutpat ac tortor nec, tempus bibendum felis. Suspendisse commodo mi eget mauris molestie condimentum. Donec egestas quis mauris ut viverra. Nunc egestas diam nisi, elementum efficitur tortor suscipit ut. Donec lobortis risus et leo mollis feugiat. Donec gravida enim sit amet fringilla rutrum. Nullam bibendum lacinia lacus, a hendrerit dolor convallis vitae. } \\

\hline
Option 1: & \begin{itemize}
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{itemize}

\\
\hline
Option 2: & \begin{itemize}
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{itemize}\\
\end{tabular}

我有一些困难:

  1. “A- 段落标题”:它是一个跟在段落后面的副标题。
  2. 第一行的长段落,超出了表格范围。
  3. 我不知道如何让“选项 1”和“选项 2”垂直排列

获得的结果:

在此处输入图片描述

此布局将在多行中重复,一行有一列,四行有两列,依此类推。

谢谢,

答案1

如果您想要换行,则必须p{<length>}在参数中使用规范。我建议您立即使用。Reg. 将“选项 1”和“选项 2”垂直放置:这很丑陋且难以阅读。我的建议是不要这样做。您可能想要的另一件事是减少 itemize 周围的垂直间距。代码:\multicolumntabularx

\documentclass[11pt]{article}

\usepackage{tabularx,booktabs,lipsum,enumitem}

\newcommand{\tablistcmd}{%
  \leavevmode\par\vspace{-\baselineskip}%
}

\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{%
  leftmargin = *           ,
  label      = \textbullet ,
  nosep                    ,
  before     = \tablistcmd ,
  after      = \tablistcmd
}

\begin{document}

\noindent
\begin{tabularx}{\linewidth}{@{}lX@{}}
  \toprule
  \multicolumn{2}{@{}p{\linewidth}@{}}{%
    \textbf{A-Paragraph title:} \lipsum*[1]
  } \\ \midrule
  Option 1: & 
              \begin{tabitemize}
              \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
              \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
              \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
              \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
              \end{tabitemize} \\ \midrule
  Option 2: & 
              \begin{tabitemize}
              \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
              \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
              \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
              \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
              \end{tabitemize}  \\
  \bottomrule
\end{tabularx}

\end{document}

在此处输入图片描述

答案2

tabularx以下是使用和 的解决方案hhline,可以改善您的单词表的外观。我itemize使用enumitem包自定义了环境中的间距:

     \documentclass{article}
\usepackage[utf8]{inputenc} %
\usepackage{fourier}

 \usepackage{tabularx,array, rotating, caption, hhline}
 \usepackage{enumitem}
  \renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}m{#1}}

    \begin{document}
\setlist[itemize]{wide =0pt, leftmargin=*, itemsep=-2pt, topsep=3pt, after=\vspace*{\dimexpr-\baselineskip + \topsep}}
\begin{tabularx}{\linewidth}{|>{\centering}p{2cm}||X| }
\hline
\multicolumn{2}{|p{\dimexpr\linewidth-2\tabcolsep-2\arrayrulewidth}|}{%
\textbf{A – Paragraph title}\smallskip\par
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ligula ligula, tristique vel consectetur et, cursus eget ante. Sed sed vulputate magna, nec imperdiet sapien. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam faucibus pellentesque rhoncus. Aenean rhoncus, nibh vitae vestibulum pharetra, quam elit aliquam tellus, ut ultricies lacus purus nec felis. Cras in convallis risus, ac consectetur nulla. Proin enim justo, volutpat ac tortor nec, tempus bibendum felis. Suspendisse commodo mi eget mauris molestie condimentum. Donec egestas quis mauris ut viverra. Nunc egestas diam nisi, elementum efficitur tortor suscipit ut. Donec lobortis risus et leo mollis feugiat. Donec gravida enim sit amet fringilla rutrum. Nullam bibendum lacinia lacus, a hendrerit dolor convallis vitae. } \\
\hhline{=t:t:=}
\rotatebox[origin=c]{90}{Option 1} & \begin{itemize}[]
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ligula ligula, tristique vel consectetur et, cursus eget ante. \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{itemize}
\\
\hhline{=::=}
\rotatebox[origin=c]{90}{Option 2} & \begin{itemize}[wide =0pt, leftmargin=*, itemsep=-2pt, topsep =2pt]
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{itemize}\\
\hhline{-||-}
\end{tabularx}

    \end{document} 

在此处输入图片描述

相关内容