迷你页面“盒子”

迷你页面“盒子”

我正在尝试使用 minipage 环境来获得类似表格的内容,但仍然有几个问题: - 方法 B4.1 和 B4.2 应放在单独的框中 - 是否可以将文本垂直居中在框中?在顶行中,我还必须将它们水平居中,但我无法垂直居中。

下面您可以找到我迄今为止使用的代码以及“表格”的外观。

你能帮忙吗?提前谢谢!

目前使用的代码:

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

最终产品的外观如下:

 _________________________________________________________
|                                                         |
|                 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

答案1

这是“仅限小页面”的方法,代码稍微清理了一下。

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

创建由垂直线分隔的两列;列垂直居中。要将列对齐到顶部或底部,可以使用可选参数:\DOUBLECOLUMN[t]{...}{...}\DOUBLECOLUMN[b]{...}{...}

该命令\HSEPARATOR绘制一条跨越列的水平线。

环境myitems封装了所使用的特定设置itemize

在此处输入图片描述

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

相关内容