2009-02-07 76 views
1

什麼是使事物正確居中的最佳方式?一旦我開始搞亂桌子,事情就會開始向左或向右移動,破壞平衡。如何做到這一切,一切都始終居中?居中表和其他元素的最簡單方法?

現在這會導致表格被搞亂,並且右邊緣離開屏幕。我能做什麼?

下面是大部分代碼,我剪掉了很多無用的函數,因爲它們幾乎都是相同的。它用於爲學校製作用例,因爲我們需要爲一個項目做大約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} 

回答

1

我不能編譯例如,由於幾個錯誤,我不知道你所說的「把事情妥善中心的最佳途徑」的意思。作爲一種水晶球類型的答案,這是你在找什麼?

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

當我們無法編譯您的示例時,很難看出問題所在。

通過查看您提供的代碼,在這種情況下表格可能並不適合。相反,你可以嘗試類似以下內容:

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

如果這無助於解決您的問題,請爲我們提供一個編譯和演示問題的最簡單示例。

相關問題