Latex 将表格和其他元素居中的最简单方法?

Latex 将表格和其他元素居中的最简单方法?,latex,Latex,使事物正确居中的最佳方法是什么?一旦我开始摆弄桌子,事情要么开始左右移动,破坏平衡。如何使一切都始终以中心为中心 现在,这将导致桌子被弄乱,并使右边缘离开屏幕。我能做什么 这是大部分代码,我删掉了很多无用的函数,因为它们几乎都是一样的。它用于为学校制作用例,因为我们需要为一个项目制作大约40个用例 \documentclass[10pt, a4paper]{article} \usepackage{booktabs} \begin{document} \newcommand{\UCStart}[

使事物正确居中的最佳方法是什么?一旦我开始摆弄桌子,事情要么开始左右移动,破坏平衡。如何使一切都始终以中心为中心

现在,这将导致桌子被弄乱,并使右边缘离开屏幕。我能做什么

这是大部分代码,我删掉了很多无用的函数,因为它们几乎都是一样的。它用于为学校制作用例,因为我们需要为一个项目制作大约40个用例

\documentclass[10pt, a4paper]{article}
\usepackage{booktabs}
\begin{document}
\newcommand{\UCStart}[2]{
    \newpage
    \subsection[UC.#1]{UC.#1}
    \begin{tabular}{|l|m{4in}|c|}
        \hline
        \textbf{UC.#1}
        & \textbf{#2} 
        & \textbf{Traceability} \\ \hline
}

\newcommand{\UCDesc}[2]{
    \textbf{Description} 
    & #1
    & #2 \\ \hline
}

\newcommand{\UCActors}[2]{
    \textbf{External Actors}
    & #1
    & #2 \\ \hline
}

% Snip... 40 odd more functions %

\newcommand{\UCEnd}{
    \end{tabular}
}

\begin{table}[!ht]
    \setlength{\extrarowheight}{2pt}
    % UC 1
    \UCStart{01}{Administrator Starts Server}
    \UCDesc{This describes the process of the administrator starting the server}{\space}
    \UCActors{Administrator}{\space}
    \UCRelated{UC.02}{\space}
    \UCPre{Server is not running}{\space}
    \UCTrigger{Administrator wants to start the server}{\space}
    \UCSeq{
        \begin{enumerate}
            \item Administrator boots up hardware
            \item Administrator starts Administrator console
            \item Administrator logins into Administrator account with the corresponding password
            \item Administrator clicks start
        \end{enumerate}
    }{\space}
    \UCPost{Conditions that must be true, in order for the use case to finish}{\space}
    \UCAltSeq{
        \textbf{Alternative Use Case 01} \newline
        \begin{itemize}
            \item UC.01.ALT.01
            \item If administrator fails authentication in step 3
            \begin{enumerate}
                \item Notify administrator of failed authentication
            \end{enumerate}
        \end{itemize}
    }{\space}
    \UCNonFunc{ ??? }{\space}
    \UCComments{ Comments Go Here }{\space}
    \UCEnd

        \end{table}
    \end{document}

由于几个错误,我无法编译您的示例,并且我不确定您所说的“使事情正确集中的最佳方法”是什么意思。作为一种水晶球式的回答,这就是你想要的吗

 \documentclass[10pt,a4paper]{article}
 \usepackage{array}
 \begin{document}
 \begin{table}
 \centering
 \begin{tabular}{
     | >{\centering\arraybackslash }p{4cm} |
       >{\centering\arraybackslash }p{6cm} |
   }
   \hline
   some centred text in cells & some more centred text in cells \\
   \hline
   centred text in cells & more centred text in cells \\
   \hline
 \end{tabular}
 \end{table}
 \end{document}

当我们无法编译您的示例时,很难看出问题所在

通过查看您提供的代码,表在这种情况下可能并不适合。相反,您可以尝试以下方法:

\documentclass[10pt,a4paper]{article}
\begin{document}

\subsection{Administrator Starts Server}
\paragraph{Description:} This describes the process of the adminsitrator starting the server.

\paragraph{Actors:} Administrator

\paragraph{Preconditions:} Server is not running.

\paragraph{Sequence:}
\begin{enumerate}
  \item Administrator boots up hardware
  \item Administrator starts Administrator console
  \item Administrator logins into Administrator account with the corresponding password
  \item Administrator clicks start
\end{enumerate}

\end{document}
在您提供的示例中,我没有看到您在“可追溯性”列中添加任何文本。要模拟此列,可以使用
\marginpar{my text}
将文本放在页边空白处,也可以使用
blahblah\hfill{}my text
将文本右对齐到与“blahblah”相同的行上。如果希望跟踪文本右对齐并在其自己的行上,请使用
\begin{flushright}my text\end{flushright}

如果这无助于解决您的问题,请为我们提供一个编译和演示问题的最小示例