伸展台

伸展台

我定義了一個自訂命令來產生一個我必須為各種實驗做的表:

\newcommand{\exptable}[3]{
\begin{center}
    \renewcommand{\arraystretch}{1.5}
    \begin{tabular}{ccc}
        \hline 
        Particle & Voltage & Flow rate \\ 
        \hline 
        #1&\SI{#2}{\volt}&\SI{#3}{\micro\liter\per\minute}  \\ 
        \hline 
    \end{tabular}
\end{center}
}

這很有效,但是表格對於不同的輸入有不同的寬度。我想更改它,使其最小寬度大於我的輸入,因此它始終具有相同的寬度(例如 7 公分或我可以設定的寬度)。

答案1

像這樣的東西嗎?

在此輸入影像描述

\documentclass{article}
\usepackage{array,siunitx}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcommand{\exptable}[4]{%
\begin{center}
    \sisetup{per-mode=symbol}
    \renewcommand{\arraystretch}{1.5}
    \begin{tabular}{@{}l*{2}{C{#4}}}
    \hline 
    Particle & Voltage & Flow rate \\ 
    \hline 
    #1&\SI{#2}{\volt}&\SI{#3}{\micro\liter\per\minute}  \\ 
    \hline 
    \end{tabular}
\end{center}
}

\begin{document}        
\exptable{Stuff}{4.5}{1.2345}{3cm}
\end{document}

相關內容