為什麼這個表格不顯示居中?

為什麼這個表格不顯示居中?
\documentclass[landscape]{scrartcl}
\usepackage{booktabs,array,enumitem,ragged2e}

\newcommand{\tablistcommand}{%
  \leavevmode\par\vspace{-\baselineskip}%
}

\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{%
  leftmargin = *               ,
  label      = \textbullet     ,
  nosep                        ,
  before     = \tablistcommand ,
  after      = \tablistcommand
}

\begin{document}
\thispagestyle{empty}
\begin{table}
  \centering
  \caption{Wide Itemized Mixed Table}
  \label{tab:wide-item-tbl}
  \begin{tabular}{@{}l*{4}{>{\RaggedRight}p{2in}}@{}}
    \toprule
    \textbf{BSL} & \textbf{Agents} & \textbf{Practices}
    & \textbf{Primary barriers} & \textbf{Secondary barriers} \\
    \midrule
    1 & Not known to consistently cause diseases in healthy adults
      & standard microbiological practices
      & \begin{tabitemize}
        \item no primary barriers required,
        \item  PPE
        \end{tabitemize}
      & bench and sink required \tabularnewline
    2 & \begin{tabitemize}
        \item Agents associated with human diseases
        \item Routes of transmission include per-cutaneous injury,
          ingestion, mucous membrane exposure
        \end{tabitemize}
      & BSL-1 practice plus:
        \begin{tabitemize}[before=]
        \item limited access
        \item Biohazard warning signs
        \item ``Sharps'' precautions
        \item Biosafety manual defining any needed waste
          decontamination or medical surveillance polices
        \end{tabitemize}
      & Primary barriers:
        \begin{tabitemize}[before=]
        \item BSCs or other physical containment devices used for all
          manipulations of agents that cause splashes or aerosols of
          infectious materials
        \item PPE: Laboratory coats, gloves, face and eye protection,
          as needed
        \end{tabitemize}
      & BSL-1 plus:
        \begin{tabitemize}[before=]
        \item Autoclave available
        \end{tabitemize}\tabularnewline
    \bottomrule
  \end{tabular}
\end{table}
\end{document}

答案1

它看起來不居中,因為它對於頁面來說太寬並且溢出了右邊距。嘗試設定不同的頁面尺寸,例如使用幾何學包裹。此外,您還可以透過選項視覺化邊距showframe。要實現兩者添加

\usepackage[showframe,left=2cm,right=2cm]{geometry}

到序言。

答案2

tabularx嘗試與寬度\linewidth和列類型一起使用>{\RaggedRight}X}。這樣您的表格將適合文字寬度。若要查看頁面佈局,您可以自行使用\uasepackage{showframe}或使用套件設計佈局geometry,例如\usepackage[margin=1in,showframe]{geometry}

透過這些措施,您將獲得以下結果:

在此輸入影像描述

考慮到上述內容,程式碼的開頭部分是:

\documentclass[landscape]{scrartcl}
\usepackage{array,booktabs,tabularx}
\usepackage{enumitem,ragged2e}
\usepackage{showframe}

\newcommand{\tablistcommand}{%
  \leavevmode\par\vspace{-\baselineskip}%
}

\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{%
  leftmargin = *               ,
  label      = \textbullet     ,
  nosep                        ,
  before     = \tablistcommand ,
  after      = \tablistcommand
}

\begin{document}
\thispagestyle{empty}
\begin{table}
  \caption{Wide Itemized Mixed Table}
  \label{tab:wide-item-tbl}
  \begin{tabularx}{\linewidth}{@{}l*{4}{>{\RaggedRight}X}@{}}
...

相關內容