如何使我的表格位于页面中央(使用页面的两个边距)?

如何使我的表格位于页面中央(使用页面的两个边距)?

我有下表,需要增大它的宽度以保持内部文本不中断为两行:

\documentclass{article}
\usepackage{tabularx}

\begin{document}

\begin{table}

\caption{}

\begin{tabularx}{1.5\textwidth}{XXX}

\hline\hline

Place & Description & Initial marking ($m_0$)\\

\hline

\texttt{MediumGen} & Maximal possible number of bacteria to infect an individual cell & 2000\\
\texttt{SalMediumStart} &  & \\
\texttt{SalCellSurf} &  & \\
\texttt{SalMedium} &  & \\
\texttt{CapCellSurf} &  & \\

\hline\hline

\end{tabularx}

\end{table}

\end{document}

看起来像:

在此处输入图片描述

有两个问题:表格没有居中并且超出了页面右侧,并且中间列的文本仍然分成两行。

感谢您的帮助!

编辑

@koleygr 的答案解决了居中问题。但是,当我们用文本填充列时,它们会重叠:

\documentclass{article}
\usepackage{tabularx}

\begin{document}

\begin{table}

\caption{}

\makebox[\textwidth][c]{\begin{tabularx}{1.5\textwidth}{XlX}

\hline\hline

Place & Description & Initial marking ($m_0$)\\

\hline

 \texttt{XenoEnd} & Signal for the termination of xenophagy & 0\\
 \texttt{XenoIniCounter} & Time counter for the initiation of xenophagy & 0\\
 \texttt{XenoEndCounter} & Time counter for the termination of xenophagy & 0\\
 \texttt{DeathSigCyt} & Signal that the cell undergoes cell death due to a high number of cytosolic \textit{Salmonella} & 0\\
 \texttt{DeathSigVac} & Signal that the cell undergoes cell death due to a high number of vacuolar \textit{Salmonella} & 0\\
 \texttt{WashIni} & Signal for the one-time initiation of the washing process & 1\\
 \texttt{WashCounter} & Time counter of the washing process & 0\\
 \texttt{WashSig} & Signal for the onset of the washing process & 0\\

 \hline\hline

 \end{tabularx}}

 \end{table}

 \end{document}

看起来像

在此处输入图片描述

是否有可能强制将中间列稍微向右侧移动一点?

答案1

欢迎加入我们的社区!

不确定你是否正在寻找这样的东西:

\documentclass{article}
\usepackage{tabularx}

\begin{document}

\begin{table}

\caption{}

\makebox[\textwidth][c]{\begin{tabularx}{1.5\textwidth}{XlX}

\hline\hline

Place & Description & Initial marking ($m_0$)\\

\hline

\texttt{MediumGen} & Maximal possible number of bacteria to infect an individual cell & 2000\\
\texttt{SalMediumStart} &  & \\
\texttt{SalCellSurf} &  & \\
\texttt{SalMedium} &  & \\
\texttt{CapCellSurf} &  & \\

\hline\hline

\end{tabularx}}

\end{table}

\end{document}

输出:

在此处输入图片描述

编辑

\documentclass{article}
%\usepackage{tabularx}
\usepackage{makecell}
\begin{document}

\begin{table}

\caption{}

\makebox[\textwidth][c]{\small\begin{tabular}{lll}

\hline\hline

Place & Description & \makecell[lt]{Initial marking\\($m_0$)}\\

\hline

 \texttt{XenoEnd} & Signal for the termination of xenophagy & 0\\
 \texttt{XenoIniCounter} & Time counter for the initiation of xenophagy & 0\\
 \texttt{XenoEndCounter} & Time counter for the termination of xenophagy & 0\\
 \texttt{DeathSigCyt} & Signal that the cell undergoes cell death due to a high number of cytosolic \textit{Salmonella} & 0\\
 \texttt{DeathSigVac} & Signal that the cell undergoes cell death due to a high number of vacuolar \textit{Salmonella} & 0\\
 \texttt{WashIni} & Signal for the one-time initiation of the washing process & 1\\
 \texttt{WashCounter} & Time counter of the washing process & 0\\
 \texttt{WashSig} & Signal for the onset of the washing process & 0\\

 \hline\hline

 \end{tabular}}

 \end{table}

 \end{document}

输出:

在此处输入图片描述

答案2

好的,这里有一个详细说明缩写方法的方法:

  • 它把一个放在list environment桌子下面float environment(这可能比那更好)
  • 它删除了\makebox
  • 它使用包varioref,当表格浮动到其他页面时,它可以更好地扩展(但需要 2 次编译运行)
  • 它把一些内容放在blindtext浮动元素下面,只是为了展示布局

附言:除了使用缩写之外,您还可以对参数进行分组,从标题(多)行开始将其写出。参见例如本数据表第 13 章

\documentclass{article}
\usepackage{tabularx}
\usepackage{varioref}% expands \vref{} statements after 2nd compile
\usepackage{blindtext}

\begin{document}

Table \vref{things} shows important aspects. There may be more, there may be less, more or less \dots

\begin{table}[h]% you chose a float environment for the tables
    \caption{This is what the thingies mean}\label{things}
    \begin{tabularx}{\textwidth}{lXp{1cm}}
        \hline\hline
        
        Place & Description & Initial marking ($m_0$)\\
        
        \hline
        
         \texttt{XenoEnd} & SFT termination of xenophagy & 0\\
         \texttt{XenoIniCounter} & TC for the initiation of xenophagy & 0\\
         \texttt{XenoEndCounter} & TC for the termination of xenophagy & 0\\
         \texttt{DeathSigCyt} & SFTCDDT high number of cytosolic \textit{Salmonella} & 0\\
         \texttt{DeathSigVac} & SFTCDDT high number of vacuolar \textit{Salmonella} & 0\\
         \texttt{WashIni} & SFT one-time initiation of the washing process & 1\\
         \texttt{WashCounter} & TC of the washing process & 0\\
         \texttt{WashSig} & SFT onset of the washing process & 0\\  
         \hline\hline
     \end{tabularx}
     
     \begin{itemize}% a way to do it; not nice, but ...
       \item SFT: Signal for, Signal that       
       \item SFTCDDT: Signal for the cell undergoing cell death due to  
       \item TC: Time Counter 
     \end{itemize}
 \end{table}

\blindtext% just to fill the page

\end{document}

结果

答案3

以下是整合 中的一些策略的方法writing good tables for data sheets,例如presenting technical information。他们试图:

  • 减少文字
  • 使相关信息更容易掌握(包括揭示当前方法中存在的缺陷)
  • 将所有东西都放在一个地方,或者靠近一个地方。

因此这些策略建议:

  • 引入new column "Type"并减少文本大小S and TC
  • explanation这些缩写移到标题中
  • 用于\multicolumn从“描述”中移除冗余文本(以及一些\hline decoration
  • 使整个文本更加清晰可见,例如通过\textsc{}
  • 使用shorter entry for the last column(除非丢弃$m_0$很重要)。

在代码中,您还会看到一些确定最后一列宽度的替代方法。例如,使用 unit em(即通过给定字体中的 m 字符数指定宽度)可能比使用 更直接cm

当然,你可以并且应该将重复模式移到专用宏 ( \newcommand) 中。例如, arow of table entry要求这样做。 the 也是如此multicolumn decoration。这将导致代码更简洁,内容呈现更统一。

结果

\documentclass{article}
\usepackage{tabularx}
\usepackage{varioref}% expands \vref{} statements after 2nd compile
\usepackage{blindtext}


\begin{document}

Table \vref{things} shows important aspects. There may be more, there may be less, more or less \dots

\begin{table}[h]% you chose a float environment for the tables
    % <<< changed caption; includes Type description
    \caption{Signals and time counters for this cell investigations, with Types \textit{S:~Signal, TC: Time Counter}}\label{things}
    
    % <<< added column "Type"  to allow for shorter text in column "Description"
    \begin{tabularx}{\textwidth}{llXc}%p{3.0em}}% <<< some variations
        \hline\hline
        
        Place & Type & Description & Initial\\% marking ($m_0$)\\% <<<why not making it shorter?
        \hline

        \texttt{XenoEnd}        & S     & termination of xenophagy & 0\\
        \texttt{XenoIniCounter} & TC    &  initiation of xenophagy & 0\\
        \texttt{XenoEndCounter} & TC    & termination of xenophagy & 0\\

        \hline
        \multicolumn{4}{l}{\textsc{Cell undergoes cell death due to:}}\\% <<< NEW
        \texttt{DeathSigCyt}    & S     &  a high number of cytosolic \textit{Salmonella} & 0\\
        \texttt{DeathSigVac}    & S     & a high number of vacuolar \textit{Salmonella} & 0\\
        \hline

        \texttt{WashIni}        & S     & one-time initiation of washing process & 1\\
        \texttt{WashCounter}    & TC    & of washing process & 0\\
        \texttt{WashSig}        & S     & onset of the washing process & 0\\

        \hline\hline
    \end{tabularx}
 \end{table}

\blindtext% just to fill the page

\end{document}

相关内容