1

I have a problem when rotating a text in \multirow cell table. The obtained rotated text is not well centered in the middle of the cell; additionally, the text seems to be not merged with the wanted cells.

Here is the code I'm using:

\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}

enter image description here

  • Try just c(last column) or >{\centering\arraybackslash}p{0.15\textwidth} instead of p{0.15\textwidth}(last column) with \usepackage{array}. – Bobyandbob Jul 30 '17 at 8:11
1

edit: it seems that in the first answer i misunderstand problem ... now i try correct this

like this?

enter image description here

for above image of table the following changes has been done:

  • added packages array, ragged2e, enumitem and etoolbox
  • changed are column width
  • removed adjustbox
  • defined new column type P and C
  • used itemize for lists in cells
  • reduced \tabcolsep distance
  • multirow for rotated text now consider correct numbers of spanned lines, i.e.: for the first multirow 11 + 1 (1 for additional space introduced by \cmidrules
  • for rules of rowsspanned with mutirow are used\cmidrule{1-4}`

changed 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}
  • Thanks very match for the improvements you make. But still, the rotated text is not merged with the 4 rows. It seems that \multirow{4} is not working. I have made the changes to the first code with regards to your changes. – khaldi Jul 30 '17 at 9:31
  • @khaldi, sorry, i don't understand you what you mean with merged. please, elaborate this! should it be over more table rows? if it, how many? – Zarko Jul 30 '17 at 9:36
  • Apologies for the delay, I mean that the rotated text for example ( Spatially organizing behaviors) should be common in the 4 rows, not only with the first one (It is common in Aggregation, pattern Formation, Chain Formation, and Self-assembly problems) – khaldi Jul 30 '17 at 10:18
  • Exactly Like Cell Merge in Excell – khaldi Jul 30 '17 at 10:27
  • @khaldi, see edited answer. hopefully is now what you like to have. comparison with excel is not very meaningful to me, i don't use it :) – Zarko Jul 30 '17 at 10:40
1

I propose this solution, based on tabularx, with less horizontal rules. To simplify the typing of the table, I defines new column type, I, which an X column entering an itemize environment, so that you only have to type the \item some text. The corresponding column head have then to be typed as \multicolumns.

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.