如何让旋转的框文本居中?

如何让旋转的框文本居中?

我想让旋转后的“第 1 章”位于中心,但这\rotatebox[origin=r]并没有什么区别。

在此处输入图片描述

以下是 MWE:

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage[pdftex]{graphicx}
\usepackage{enumitem}
\usepackage{pifont}
\usepackage{longtable, tabularx, makecell}
\usepackage{array,multirow,amssymb}
\usepackage{setspace}
\pagestyle{plain}
\setlength\parindent{0pt}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother

\newcolumntype{L}{>{\arraybackslash\compress}X}
\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash\compress}m{#1}}

\begin{document}

% 
\setlist[itemize]{label=\ding{254}, wide=0pt, leftmargin=*, itemsep=0pt, before=\vspace*{\topsep}, after =\vspace*{-\topsep}}
\setlength{\extrarowheight}{3pt}
\small
\begin{longtable}{|p{0.1\textwidth}|p{0.84\textwidth}|}\hline
 \multicolumn{1}{|c|}{Chapter } & \multicolumn{1}{l|}{\textbf{Content}} \\
\hline
\rotatebox[origin=r]{90}{\makecell{Chapter 1\\Center \\ and Core Center}}
 & \begin{itemize}
    \item Part 1

    \vspace{-12pt}

    \begin{itemize}[label=\ding{229}]
    \item First 
    \item Second
    \item Third
    \item Fourth
    \end{itemize}
    \item Part 2

    \vspace{-12pt}

    \begin{itemize}[label=\ding{229}]
    \item I
    \item II
    \item III
    \end{itemize}
\end{itemize}
\\
\hline

\end{longtable}

\end{document} 

答案1

这是我的建议:我用 替换了longtable环境,该环境结合了和 的xltabular功能。为了垂直居中旋转的第一列的内容,我结合使用了垂直居中的类型列(参见)和选项。我还引入了一个新的类似于 itemize 的环境供表格使用,并用更自动化的方法替换了手动间距命令和标签选项:longtabletabularxX\renewcommand{\tabularxcolumn}[1]{m{#1}}[origin=c]\rotatebox

在此处输入图片描述

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{pifont}
\usepackage{makecell}
\usepackage{xltabular}
\pagestyle{plain}
\setlength\parindent{0pt}


\renewcommand{\tabularxcolumn}[1]{m{#1}}

\newlist{tabitem}{itemize}{2} %<----- New itemize like environment for the use in tables (2 levels)
\setlist[tabitem]{wide=0pt, 
                 leftmargin=*, 
                 itemsep=0pt, 
                 before=\vspace{-0.6\baselineskip}} %<----- Common setting for all itemize levels.
\setlist[tabitem,1]{label=\ding{254}, 
                    after=\vspace{-1\baselineskip}} %<----- Additional settings for the first itemize level.
\setlist[tabitem,2]{label=\ding{229}, 
                    after=\vspace{-0.25\baselineskip}} %<----- Additional settings for the second itemize level.

\begin{document}



\setlength{\extrarowheight}{3pt}
\small
\begin{xltabular}{\textwidth}{|c|X|}\hline
Chapter & \textbf{Content} \\
\hline
\rotatebox[origin=c]{90}{\makecell{Chapter 1\\Center \\ and Core Center}}
 & \begin{tabitem}
     \item Part 1
     \begin{tabitem}
        \item First 
        \item Second
        \item Third
        \item Fourth
     \end{tabitem}
     \item Part 2
     \begin{tabitem}
       \item I
       \item II
       \item III
     \end{tabitem}
   \end{tabitem}
\\ \hline
\end{xltabular}
\end{document} 

答案2

另一种解决方案是,使用可选参数来 \multirow调整其内容的垂直位置,并对 itemize 参数进行稍微修改:

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage[pdftex]{graphicx}
\usepackage{enumitem}
\usepackage{pifont}
\usepackage{longtable, tabularx, makecell}
\usepackage{array,multirow,amssymb}
\usepackage{setspace}
\pagestyle{plain}
\setlength\parindent{0pt}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother

\newcolumntype{L}{>{\arraybackslash\compress}X}
\renewcommand{\tabularxcolumn}[1]{>{\compress\arraybackslash}m{#1}}

\begin{document}

%
\setlist[itemize, 1]{label=\ding{254}, wide=0pt, leftmargin=*, itemsep=0pt, before = \vspace{-\baselineskip}, after =\vspace*{-\dimexpr\baselineskip + \topsep}}
\setlength{\extrarowheight}{3pt}
\small
\begin{longtable}{|p{0.1\textwidth}| >{\compress\arraybackslash}p{0.84\textwidth}|}\hline
 \multicolumn{1}{|c|}{Chapter } & \multicolumn{1}{l|}{\textbf{Content}} \\
\hline
\multirow{1}{=}[-2.4ex]{\rotatebox[origin=br]{90}{\makecell{\bigstrut[t] Chapter 1\\Center \\ and Core Center}}}
 & \begin{itemize}
    \item Part 1

    \vspace{-12pt}

    \begin{itemize}[label=\ding{229}]
    \item First
    \item Second
    \item Third
    \item Fourth
    \end{itemize}
    \item Part 2

    \vspace{-12pt}

    \begin{itemize}[label=\ding{229}]
    \item I
    \item II
    \item III
    \end{itemize}
\end{itemize}
\\
\hline

\end{longtable}

\end{document} 

在此处输入图片描述

相关内容