我在 \multirow cell table 中旋转文本时遇到问题。获得的旋转文本未在单元格中间居中;此外,文本似乎未与所需单元格合并。
以下是我使用的代码:
\documentclass{article}
\usepackage{graphicx,multirow}
\usepackage{adjustbox}
\usepackage{chngpage}
\usepackage{booktabs}
\begin{document}
\begin{table}
\caption{ Classifications of problems being studied in Swarm robotics.}
\label{tab:classification}
\centering
\begin{adjustwidth}{-.5in}{-.5in}
\begin{adjustbox}{max width=1.2\textwidth}
\begin{tabular}{p{0.4\textwidth} p{0.35\textwidth} p{0.32\textwidth} p{0.2\textwidth} p{0.15\textwidth}}
\toprule
Problematic &Sources of inspiration & Modeling approaches & Research literatures samples & Classification\\
\midrule
\textbf{Aggregation}: Clustering swarm robots in a region of the environment.
&
- Nature (e.g. Aggregation bacteria, cockroaches, bees, fish and penguins).
&
- Probabilistic finite state machines.\newline
- Artificial evolution.&
- [20] and [21] &
\multirow{4}{*}{\rotatebox[origin=c]{90}{Spatially organizing behaviors}}
\\
\midrule
\textbf{Pattern formation}: Deploying robots in a regular and repetitive manner from
which specific distances are kept between each other in order to create a desired
pattern. &
- Biology (e.g. the spatial disposition of bacterial colonies and the chromatic patterns on some animals). \newline
- Physics (e.g. molecules distribution and crystal formation).&
- Virtual physics-based design. &
- [22] &
\\
\midrule
\textbf{Chain formation}: Auto-Positioning robots to connect into two points. The
chain that they form can then be used as a guide for navigation or for
surveillance. &
- Foraging ants. &
- Probabilistic finite state machines.\newline
- Virtual physics based design.\newline
- Artificial evolution&
- [23] and [24] &
\\
\midrule
\textbf{Self-assembly and morphogenesis}: Connecting physically swarm robots to each other to create structures (morphologies). &
- Foraging ants. &
- Probabilistic finite state machines.\newline
- Virtual physics based design.\newline
- Artificial evolution &
- [23] and [24] &
\\
\midrule
\textbf{Collective exploration} &
- Social animals (ants, bees…). &
- Probabilistic finite state machines.\newline
- Virtual physics-based design.\newline
- Network routing &
- [26] and [27] &
\multirow{3}{*}{\rotatebox[origin=c]{90}{Navigation behaviors}}
\\
\midrule
\textbf{Coordination motion}: Moving in formation similarly to schools of fish or
flocks of birds. &
- Flocking in-group of birds.\newline
- Schooling in group of fish. &
- Virtual physics-based design.\newline
- Artificial evolution&
- [28] &
\\
\midrule
\textbf{Collective transport}: Cooperating in order to transport an object. &
- Cooperative carry prey in ant colonies.&
- Probabilistic finite state machines.\newline
- Artificial evolution &
- [29] &
\\
\midrule
\textbf{Consensus achievement}: Reaching consensus on one choice among different
alternatives. &
- Ants’ decision between the shorter of two paths using pheromones.\newline
- Bees’ decision between the best foraging area and the best nest location.\newline
- Aggregation in Cockroaches &
- Direct communication.\newline
- Indirect communication.
&
- [30] and [31]&
\multirow{2}{*}{\rotatebox[origin=c]{90}{Collective decision making}}\\
\midrule
\textbf{Task allocation}: Auto-distribution of swarm robots over different tasks To maximize the performance of the system. &
- Task allocation in ant and bee colonies. &
- Probabilistic finite state machines. &
- [32] & \\
\bottomrule\\
\end{tabular}
\end{adjustbox}
\end{adjustwidth}
\end{table}
\end{document}
答案1
编辑:看来在第一个答案中我误解了这个问题......现在我尝试纠正它
像这样?
对于上表的图像,进行了以下更改:
- 添加了软件包
array
、ragged2e
和enumitem
etoolbox
- 改变列宽
- 已删除
adjustbox
- 定义新的列类型
P
和C
- 用于
itemize
单元格中的列表 - 减小
\tabcolsep
距离 multirow
对于旋转的文本,现在考虑正确的跨行数,即:对于前multirow
11 + 1(1 为\cmidrule
s引入的额外空间mutirow are used
对于使用\cmidrule{1-4}`的行跨度规则
更改 mwe:
\documentclass{article}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{chngpage}
\usepackage{array, booktabs, multirow}
\usepackage{ragged2e}
\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{table}{%
\setlist[itemize]{nosep, % <-- new list setup
leftmargin = * ,
label = $\bullet$ ,
before = \vspace{-0.6\baselineskip},
after = \vspace{-\baselineskip}
}
}
\newcolumntype{P}[1]{>{\RaggedRight}p{#1}}
\newcolumntype{C}[1]{>{\Centering}p{#1}}
\begin{document}
\begin{table}
\setlength\tabcolsep{3pt}
\caption{ Classifications of problems being studied in Swarm robotics.}
\label{tab:classification}
\centering
\begin{adjustwidth}{-.18\textwidth}{-.18\textwidth}
\begin{tabular}{P{0.4\textwidth} P{0.3\textwidth} P{0.3\textwidth} P{0.2\textwidth} C{0.1\textwidth}}
\toprule
Problematic
& Sources of inspiration
& Modeling approaches
& Research literatures samples
& Classi\-fication
\\ \midrule
\textbf{Aggregation}: Clustering swarm robots in a region of the environment.
&
\begin{itemize}
\item Nature (e.g. Aggregation bacteria, cockroaches, bees, fish and penguins).
\end{itemize}
&
\begin{itemize}
\item Probabilistic finite state machines.
\item Artificial evolution.
\end{itemize}
& [20] and [21] &
\multirow{12}{*}{\rotatebox{90}{Spatially organizing behaviors}}
\\ \cmidrule{1-4}
\textbf{Coordination motion}: Moving in formation similarly to schools of fish or
flocks of birds.
&
\begin{itemize}
\item Flocking in-group of birds.
\item Schooling in group of fish.
\end{itemize}
&
\begin{itemize}
\item Virtual physics-based design.
\item Artificial evolution
\end{itemize}
& [28] &
\\ \cmidrule{1-4}
\textbf{Collective transport}: Cooperating in order to transport an object.
&
\begin{itemize}
\item Cooperative carry prey in ant colonies.
\end{itemize}
&
\begin{itemize}
\item Probabilistic finite state machines.
\item Artificial evolution
\end{itemize}
& [29] &
\\ \midrule
%
\textbf{Consensus achievement}: Reaching consensus on one choice among different
alternatives.
&
\begin{itemize}
\item Ants’ decision between the shorter of two paths using pheromones.
\item Bees’ decision between the best foraging area and the best nest location.
\item Aggregation in Cockroaches
\end{itemize}
&
\begin{itemize}
\item Direct communication.
\item Indirect communication.
\end{itemize}
& [30] and [31] &
\multirow{15}{*}{\rotatebox[origin=c]{90}{Collective decision making}}
\\ \cmidrule{1-4}
\textbf{Task allocation}: Auto-distribution of swarm robots over different tasks To maximize the performance of the system.
&
\begin{itemize}
\item Task allocation in ant and bee colonies.
\end{itemize}
&
\begin{itemize}
\item Probabilistic finite state machines.
\end{itemize}
& [32] & \\
\bottomrule
\end{tabular}
\end{adjustwidth}
\end{table}
\end{document}
答案2
我建议采用基于 的解决方案tabularx
,减少水平线。为了简化表格的输入,我定义了新的列类型,I
即X
输入itemize
环境的列,这样您只需输入\item some text
。相应的列标题则必须输入为\multicolumn
s。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{adjustbox}%, rotating
\usepackage{changepage}
\usepackage{tabularx, multirow, makecell, caption, booktabs}
\renewcommand\theadfont{\small}
\usepackage{ragged2e}
\usepackage{enumitem}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\newcolumntype{I}{>{\compress\RaggedRight\itemize[nosep, wide=0pt, label=\textendash, leftmargin=*, before=\compress, ]}X<{\enditemize}}
\begin{document}
\begin{table}[!htb]
\small\centering
\setlength\tabcolsep{4pt}
\captionsetup{skip=6pt}
\caption{ Classifications of problems being studied in Swarm robotics.}
\label{tab:classification}
\centering
\begin{adjustwidth}{-0.15\textwidth}{-0.15\textwidth}
\begin{tabularx}{\linewidth}{@{}>{\RaggedRight}p{5.6cm}IIl@{\quad}c}
\toprule
Problematic & \multicolumn{1}{c}{Sources of inspiration} & \multicolumn{1}{c}{Modeling approaches} & \thead{Research \\ literatures \\ samples} & \rotatebox[origin=c]{90}{~Classif. }\\
\midrule
\textbf{Aggregation}: Clustering swarm robots in a region of the environment.
& \item Nature (e.g. Aggregation bacteria, cockroaches, bees, fish and penguins).
&
\item Probabilistic finite state machines.
\item Artificial evolution.
& [20] and [21]
& \multirowcell{18}[-4ex]{\rotatebox{90}{Spatially organizing behaviors}}
\\
\textbf{Pattern formation}: Deploying robots in a regular and repetitive manner from
which specific distances are kept between each other in order to create a desired
pattern.
&
\item Biology (e.g. the spatial disposition of bacterial colonies and the chromatic patterns on some animals).
\item Physics (e.g. molecules distribution and crystal formation).
& \item Virtual physics-based design.
& [22] &
\\
\textbf{Chain formation}: Auto-Positioning robots to connect into two points. The
chain that they form can then be used as a guide for navigation or for
surveillance.
& \item Foraging ants.
&
\item Probabilistic finite state machines.
\item Virtual physics based design.
\item Artificial evolution
&
[23] and [24] &
\\
\addlinespace[2ex]
\textbf{Self-assembly and morphogenesis}: Connecting physically swarm robots to each other to create structures (morphologies).
& \item Foraging ants.
&
\item Probabilistic finite state machines.
\item Virtual physics based design.
\item Artificial evolution
& [23] and [24] &
\\
\midrule
\textbf{Collective exploration}
& \item Social animals (ants, bees…).
&
\item Probabilistic finite state machines.
\item Virtual physics-based design.
\item Network routing
& [26] and [27] &
\multirowcell{8}[-2.5ex]{\rotatebox[origin=c]{90}{Navigation behaviors}}
\\
\textbf{Coordination motion}: Moving in formation similarly to schools of fish or flocks of birds.
&
\item Flocking in-group of birds.
\item Schooling in group of fish.
&
\item Virtual physics-based design.
\item Artificial evolution
& [28] &
\\
\addlinespace[2ex]
\textbf{Collective transport}: Cooperating in order to transport an object.
& \item Cooperative carry prey in ant colonies.
&
\item Probabilistic finite state machines.
\item Artificial evolution
& [29] &
\\
\addlinespace[-2.5ex]
\midrule
\textbf{Consensus achievement}: Reaching consensus on one choice among different alternatives.
&
\item Ants’ decision between the shorter of two paths using pheromones.
\item Bees’ decision between the best foraging area and the best nest location.
\item Aggregation in Cockroaches
&
\item Direct communication.
\item Indirect communication.
& [30] and [31] %
& \multirowcell{10}[-1.7ex]{\rotatebox[origin=l]{90}{Collective decision making}}
\\%
\textbf{Task allocation}: Auto-distribution of swarm robots over different tasks To maximize the performance of the system.
& \item Task allocation in ant and bee colonies.
& \item Probabilistic finite state machines.
& [32] & \\
\bottomrule
\end{tabularx}
\end{adjustwidth}
\end{table}
\end{document}