1

I am trying to get something like a table by using the minipage environment, but I still have a couple of problems: - Methods B4.1 and B4.2 should go in separate boxes - Is it possible to center the text in the boxes vertically? In the top rows I also have to center them horizontally, but I could not manage to do it vertically.

Below you can find the code I am using so far and how the "table" should look like.

Can you please help? Thanks a lot in advance!

Code used so far:

\noindent
\fbox{\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule}
\setlength\parskip{\baselineskip}
\smallskip
{\centering\Large\textbf{\MakeUppercase{Methodology for A and B, two lines text}}\par}

\bigskip
\hrule height\fboxrule

\begin{minipage}[t]{\dimexpr(.5\linewidth-2\fboxsep-\fboxrule)}%
\setlength\parskip{\baselineskip}
\begin{center}
\textbf{Methods for A}
\end{center}

\bigskip
\hrule height\fboxrule
\textbf{Methods for A1}

\bigskip
\hrule height\fboxrule

\textbf{Methods for A2}
\begin{itemize}[noitemsep,topsep=-20pt]
\item[--] name 1
\item[--] name 2
\end{itemize}

\bigskip\bigskip\bigskip
\hrule height\fboxrule

\textbf{Methods for A3}

\begin{itemize}[noitemsep,topsep=-20pt]
\item[--] name 3
\item[--] name 4
\end{itemize}

\bigskip\bigskip\bigskip
\hrule height\fboxrule

\textbf{Methods for A4}

\begin{itemize}[noitemsep,topsep=-20pt]
\item[--] name 5
\item[--] name 6
\item[--] name 7
\end{itemize}
\bigskip\bigskip\bigskip
\end{minipage}%
\hfill\vrule width\fboxrule\hfill
\begin{minipage}[t]{\dimexpr(.5\linewidth-2\fboxsep-\fboxrule)}%
\setlength\parskip{\baselineskip}
\begin{center}
\textbf{Methods for B}
\end{center}

\bigskip
\hrule height\fboxrule

\textbf{Methods B1}

\bigskip
\hrule height\fboxrule

\textbf{Methods B2}

\bigskip
\hrule height\fboxrule

\textbf{Methods B3}

\begin{itemize}[noitemsep,topsep=-20pt]
\item[--] name 8
\item[--] name 9
\item[--] name 10
\end{itemize}
\bigskip\bigskip\bigskip
\hrule height\fboxrule


\begin{minipage}[t]{\dimexpr(.5\linewidth-2\fboxsep-\fboxrule)}%

\textbf{Methods B4}

\bigskip
\hrule height\fboxrule
\end{minipage}%

\begin{minipage}[t]{\dimexpr(.5\linewidth-2\fboxsep-\fboxrule)}%

\textbf{Methods B4.1}

\begin{itemize}[noitemsep,topsep=-20pt]
\item[--] name 11
\item[--] name 12
\end{itemize}
\bigskip\bigskip\bigskip
\hrule height\fboxrule
\bigskip
\textbf{Methods B4.2}

\begin{itemize}[noitemsep,topsep=-20pt]
\item[--] name 13
\item[--] name 14
\end{itemize}
\bigskip\bigskip\bigskip

\end{minipage}%

\bigskip
\hrule height\fboxrule

\textbf{Methods B5}
\begin{itemize}[noitemsep,topsep=-20pt]
\item[--] name 15
\item[--] name 16
\end{itemize}
\bigskip\bigskip\bigskip
\hrule height\fboxrule

\textbf{Methods B6}
\begin{itemize}[noitemsep,topsep=-20pt]
\item[--] name 17
\item[--] name 18
\end{itemize}

\bigskip\bigskip\bigskip

\end{minipage}%
\end{minipage}}

How the final product should look like:

 _________________________________________________________
|                                                         |
|                 Methodology for A and B                 |
|                      two lines text                     |
|_________________________________________________________|
|        Methods with A      |     Methods with B         | <-- evenly distributed and centered in the cell, the two column must have the same size (the page size in total)
|____________________________|____________________________|      
|                            |                            |       
|                            | Method B1                  |       
| Method A1                  |____________________________|      
|                            |                            |       
|____________________________| Method B2                  |       
|                            |____________________________|    
|                            |                            |
| Method A2                  | Method B3                  |
|    - name 1                |    - name 3                |
|    - name 2                |    - name 4                |
|____________________________|    - name 5                |
|                            |____________________________|     
|                            |              |             | <-- evenly distributed and centered. The two multi-row must have the same size        
| Method A3                  |              | Method B4.1 |        
|    - name 6                |              |    - name 8 | 
|    - name 7                |              |    - name 9 |       
|                            |              |             |        
|                            | Method B4    |_____________|        
|                            |              |             |        
|                            |              | Method B4.1 |        
|                            |              |    - name 10|       
|____________________________|              |    - name 11|  
|                            |______________|_____________|
|                            |                            |
|                            | Method B5                  |
|                            |    - name 12               |
|  Method A4                 |    - name 13               |
|     - name 14              |                            |
|     - name 15              |____________________________|
|     - name 16              |                            |
|                            | Method B6                  |
|                            |    - name 17               |
|                            |    - name 18               |
|____________________________|____________________________| 
   ^                                ^
  always aligned on the left and centered in the cell
  the real text inside sometimes could big slightly bigger and might have to go on a second line
  • This is table, rather, nothing for glueing boxes to together manually – user31729 Feb 12 '17 at 11:49
  • @ChristianHupfer This is the second post regarding this issue, and David recommended to use minipages. – gernot Feb 12 '17 at 13:42
  • @gernot: Oh really, did he? Well, I wouldn't anyway. – user31729 Feb 12 '17 at 13:43
  • 1
    Possible duplicate of Issues with a complex table – Zarko Feb 12 '17 at 15:05
  • @Zarko Why do you want to close this question again?. The OP's first question was closed with reference to "Issues with a complex table". This new question is the result of applying the method that David recommended in "Issues with a complex table". I think this is a tricky issue and a clean and simple solution is not obvious. – gernot Feb 12 '17 at 15:23
2

Here is the "minipages only" approach, with the code cleaned up a bit.

\DOUBLECOLUMN{contents left column}{contents right column}

creates two columns separated by a vertical rule; the columns are centered vertically. To align the columns at the top or bottom, you can use an optional argument: \DOUBLECOLUMN[t]{...}{...} or \DOUBLECOLUMN[b]{...}{...}.

The command \HSEPARATOR draws a horizontal rule spanning the column.

The environment myitems encapsulates the specific settings used with itemize.

enter image description here

\documentclass{article}
\usepackage{enumitem}
\renewcommand\labelitemi{--}
\newenvironment{myitems}%
  {\begin{itemize}[noitemsep,topsep=0pt]}%
  {\end{itemize}}
\newcommand\HSEPARATOR{\unskip\par\medskip\hrule height\fboxrule\par\medskip}
\newcommand\VSEPARATOR{\hfill\vrule width\fboxrule\hfill}
\newcommand\DOUBLECOLUMN[3][]%
  {\begin{minipage}[#1]{\dimexpr.5\linewidth-2\fboxsep-\fboxrule}
   #2
   \end{minipage}%
   \VSEPARATOR
   \begin{minipage}[#1]{\dimexpr.5\linewidth-2\fboxsep-\fboxrule}
   #3
   \end{minipage}%
  }
\begin{document}

\noindent
\fbox{\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule}
  \begin{center}\Large\bfseries\scshape
    Methodology for A and B\\
    two lines text
  \end{center}
  \HSEPARATOR
  \DOUBLECOLUMN[t]%
    {{\centering\bfseries
       Methods for A%
     }
     \HSEPARATOR
     \textbf{Methods for A1}
     \HSEPARATOR
     \textbf{Methods for A2}
     \begin{myitems}
       \item name 1
       \item name 2
     \end{myitems}
     \HSEPARATOR
     \textbf{Methods for A3}
     \begin{myitems}
       \item name 3
       \item name 4
     \end{myitems}
     \HSEPARATOR
     \textbf{Methods for A4}
     \begin{myitems}
       \item name 5
       \item name 6
       \item name 7
     \end{myitems}
    }%
    {{\centering\bfseries
       Methods for B%
     }
     \HSEPARATOR
     \textbf{Methods B1}
     \HSEPARATOR
     \textbf{Methods B2}
     \HSEPARATOR
     \textbf{Methods B3}
     \begin{myitems}
       \item name 8
       \item name 9
       \item name 10
     \end{myitems}
     \HSEPARATOR
     \DOUBLECOLUMN
       {\textbf{Methods B4}%
       }%
       {\textbf{Methods B4.1}
        \begin{myitems}
          \item name 11
          \item name 12
        \end{myitems}
        \HSEPARATOR
        \textbf{Methods B4.2}
        \begin{myitems}
          \item name 13
          \item name 14
        \end{myitems}%
       }
     \HSEPARATOR
     \textbf{Methods B5}
     \begin{myitems}
       \item name 15
       \item name 16
     \end{myitems}
     \HSEPARATOR
     \textbf{Methods B6}
     \begin{myitems}
       \item name 17
       \item name 18
     \end{myitems}
    }
  \end{minipage}%
} % end \fbox
\end{document}
| improve this answer | |
  • Thanks a lot, is there a way to align the columns in the center? I tries to simply remove the optional argument [t] but got a weird result. – Enrico Feb 12 '17 at 18:26
  • When you remove the optional argument, you center the whole columns with respect to each other, which means centering the shorter column vertically with respect to the other. I'm not sure what you mean by aligning the columns in the center. If you mean spreading the shorter column such that it occupies the same space vertically as the longer one: This is hard (but not impossible) to do automatically, since when typesetting the first column, the length of the second column is unknown. You have to insert space manually. – gernot Feb 12 '17 at 18:36
  • Sorry I was not very clear, I mean to center vertically the text in each of the cells, but actually I see that I can play a bit with bigskip and smallskip and do it manually, it is still effective. – Enrico Feb 12 '17 at 19:27

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.