居中长表并改变行距

居中长表并改变行距

这是我的代码:

\documentclass[11pt,twoside]{report}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{multicol}
\usepackage{array}
\usepackage{longtable}
\begin{document}
    \begin{longtable}[c]{|m{0.3\linewidth}|m{0.7\linewidth} |}  
   \hline      \textbf{Symbol} &  \textbf{Definition}
        \\\hline       \endfirsthead 
        \hline     
%   \textbf{Symbol} &  \textbf{Definition}
    %   \\\hline   
    %   \endhead   
$X$    & Unwatermarked dataset   \\

$X^{\prime}$                 & A watermarked dataset                                                                     \\
$\overline{X}$                              & The mean of the dataset $X$                                                               \\
$\overline{X^{\prime}}$                     & The mean of the dataset $X^{\prime}$                                                      \\
$G$                                         & Pseudorandom number generator                                                             \\
$K$                                         & The watermark                                                                             \\
$n$                                         & The length of the dataset, and the watermark sequence                                     \\
$SH_{key}$                                  & A secret key used to shuffle the data                                                     \\
$S$                                         & The sequence generated via the pseudorandom number generator                              \\
$\hat{X}$                                   & A copy of the data expected to be watermarked                                             \\
$S_{X}^{2}$                                 & Variance for the dataset $X$                                                              \\
$S_{X^{\prime}}^{2}$                        & Variance for the dataset $X^{\prime}$                                                     \\
$s_{i}$                                     & Individual element in the sequence $S$ at the position $i$                                \\
$P$                                    & The probability for a variable                                                            \\
$T$                                         & Sequence follows a Gaussian $N(0,1)$ distribution                                         \\
$t_{i}$                                     & Individual element in the sequence $T$ at the position $i$                                \\
$M$                                         & A secret value kept with the watermarker in the watermarking algorithm 2                  \\
$\epsilon$                                  & Determines the error in the results of the watermarked dataset $X^{\prime}$               \\
a, b, $\lambda$                             & Parameters used to watermark the dataset $X$ using the watermarking algorithm 2           \\
$x_{i}$                                     & Individual element in the sequence $X$ at the position $i$                                \\
$x_{i}^{\prime}$                            & Individual element in the sequence $X'$ at the position $i$                               \\
$\left|t_{i}\right|$                        & Absolute value of $t_{i}$                                                                 \\
$\hat{M}$                                   & The verified secret value in the watermarked data $\hat{X}$                               \\
$E(.)$                                      & Encryption function                                                                       \\
%$\mathcal{O}$                               & Time complexity                                                                           \\
$\overline{n}$                              & Represents the RLWE dimension                                                             \\
$q$                                         & The ciphertext modulus                                                                    \\
$X^{\prime\prime}$                          & Watermarked and obfuscated dataset                                                        \\
$Obf_{key}$                                 & Secret key used to obfuscate and deobfuscate data                                         \\
$\hat{x}_{i}$                               & Individual element in the sequence $\hat{X}$ at the position $i$                          \\
$C$                                         & A column of data                                                                          \\%delete it? because it conflicts with...
$r$                                         & The number of ones in a binary sequence                                                   \\
$Bob_{RK}$                                  & Bob's repacking key                                                                       \\
$Bob_{SwK}$                                 & Bob's key for the key-switch function                                                     \\
$Bob_{pk}$                                  & Bob's public key                                                                          \\
$Bob_{EK}$                                  & Bob's evaluation key                                                                      \\
$Bob_{RotK}$                                & Bob's rotation key                                                                        \\
$Bob_{RelK}$                                & Bob's relinearization key                                                                 \\
$Bob_{s}$                                   & Bob's secret key                                                                          \\
$\textbf{g}_{digit}$                        & The digit decomposition gadget                                                            \\
$\textbf{g}_{rns}$                          & The RNS decomposition gadget                                                              \\
$\Delta$                                    & The scaling factor                                                                        \\
$\underline{n}$                             & Represents the LWE dimension for the input into the look-up table                         \\
$n^\prime$                                  & Represents the LWE dimension for the output of the look-up table                          \\
$\Delta$                                    & The scaling factor                                                                        \\
$B_{ks}$                                    & The digit decomposition base                                                              \\
$h$                                         & The hamming weight                                                                        \\
$msg$                                       & Indicates the message interval that the look-up table can process                         \\
$S2C$                                       & Slot to coefficient function                                                              \\
$moduli$                                    & Represents the multiplicative depth for a ciphertext                                      \\
$\mu$s                                      & Microseconds                                                                              \\\hline
  \end{longtable}
\end{document}

问题是它没有在第二页居中,而且行距很小!任何帮助都非常感谢!

答案1

您的表格未居中,因为您没有考虑 的值\tabcolsep,因此它太宽而无法容纳线宽。我稍微减小了第一列的宽度,现在它居中了。至于行间距,该cellspace包允许您在默认情况下以字母为前缀的说明符的列中定义单元格顶部和底部的最小垂直间距S(或者C如果您加载siunitx,或任何您想要的字母,并带有加载时间选项)。希望此代码提供更符合您要求的结果:

    \documentclass[11pt,twoside]{report}
    \usepackage{amsmath}
    \usepackage{tabularx}
    \usepackage{multicol}
    \usepackage{array}
    \usepackage{longtable}
    \usepackage{cellspace}
    \setlength{\cellspacetoplimit}{6pt}
    \setlength{\cellspacebottomlimit}{6pt}
    \usepackage{lipsum}

    \begin{document}
     \lipsum[11]
        \begin{longtable}[c]{|S{m{0.2\linewidth}}|S{m{0.7\linewidth}} |}
       \hline \textbf{Symbol} & \textbf{Definition}
            \\\hline \endfirsthead
            \hline
    $X$ & Unwatermarked dataset \\

    $X^{\prime}$ & A watermarked dataset \\
    $\overline{X}$ & The mean of the dataset $X$ \\
    $\overline{X^{\prime}}$ & The mean of the dataset $X^{\prime}$ \\
    $G$ & Pseudorandom number generator \\
    $K$ & The watermark \\
    $n$ & The length of the dataset, and the watermark sequence \\
    $SH_{key}$ & A secret key used to shuffle the data \\
    $S$ & The sequence generated via the pseudorandom number generator \\
    $\hat{X}$ & A copy of the data expected to be watermarked \\
    $S_{X}^{2}$ & Variance for the dataset $X$ \\
    $S_{X^{\prime}}^{2}$ & Variance for the dataset $X^{\prime}$ \\
    $s_{i}$ & Individual element in the sequence $S$ at the position $i$ \\
    $P$ & The probability for a variable \\
    $T$ & Sequence follows a Gaussian $N(0,1)$ distribution \\
    $t_{i}$ & Individual element in the sequence $T$ at the position $i$ \\
    $M$ & A secret value kept with the watermarker in the watermarking algorithm 2 \\
    $\epsilon$ & Determines the error in the results of the watermarked dataset $X^{\prime}$ \\
    a, b, $\lambda$ & Parameters used to watermark the dataset $X$ using the watermarking algorithm 2 \\
    $x_{i}$ & Individual element in the sequence $X$ at the position $i$ \\
    $x_{i}^{\prime}$ & Individual element in the sequence $X'$ at the position $i$ \\
    $\left|t_{i}\right|$ & Absolute value of $t_{i}$ \\
    $\hat{M}$ & The verified secret value in the watermarked data $\hat{X}$ \\
    $E(.)$ & Encryption function \\
    %$\mathcal{O}$ & Time complexity \\
    $\overline{n}$ & Represents the RLWE dimension \\
    $q$ & The ciphertext modulus \\
    $X^{\prime\prime}$ & Watermarked and obfuscated dataset \\
    $Obf_{key}$ & Secret key used to obfuscate and deobfuscate data \\
    $\hat{x}_{i}$ & Individual element in the sequence $\hat{X}$ at the position $i$ \\
    $C$ & A column of data \\%delete it? because it conflicts with...
    $r$ & The number of ones in a binary sequence \\
    $Bob_{RK}$ & Bob's repacking key \\
    $Bob_{SwK}$ & Bob's key for the key-switch function \\
    $Bob_{pk}$ & Bob's public key \\
    $Bob_{EK}$ & Bob's evaluation key \\
    $Bob_{RotK}$ & Bob's rotation key \\
    $Bob_{RelK}$ & Bob's relinearization key \\
    $Bob_{s}$ & Bob's secret key \\
    $\textbf{g}_{digit}$ & The digit decomposition gadget \\
    $\textbf{g}_{rns}$ & The RNS decomposition gadget \\
    $\Delta$ & The scaling factor \\
    $\underline{n}$ & Represents the LWE dimension for the input into the look-up table \\
    $n^\prime$ & Represents the LWE dimension for the output of the look-up table \\
    $\Delta$ & The scaling factor \\
    $B_{ks}$ & The digit decomposition base \\
    $h$ & The hamming weight \\
    $msg$ & Indicates the message interval that the look-up table can process \\
    $S2C$ & Slot to coefficient function \\
    $moduli$ & Represents the multiplicative depth for a ciphertext \\
    $\mu$s & Microseconds \\\hline
      \end{longtable}

     \end{document} 

在此处输入图片描述

答案2

一年后(之前没注意到这个问题……)

  • 对于表我将使用longtblr带有tabularray库的包amsmathbooktabssiunitx
  • 另外使用mathtools包来定义分隔符
  • 在序言中定义了数学运算符,用于变量标签或名称:
\documentclass[11pt,twoside]{report}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}                             % for dummy text
\usepackage[latin]{babel}
%---------------------------------------------------------------%
\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs, siunitx}
\DeclareMathOperator{\key}{key}
\DeclareMathOperator{\bob}{Bob}
\DeclareMathOperator{\rk}{RK}
\DeclareMathOperator{\swk}{SwK}
\DeclareMathOperator{\pk}{pk}
\DeclareMathOperator{\ek}{ek}
\DeclareMathOperator{\rotk}{RotK}
\DeclareMathOperator{\relk}{RelK}
\DeclareMathOperator{\digit}{digit}
\DeclareMathOperator{\rns}{rns}
\DeclareMathOperator{\s2c}{S2C}
\DeclareMathOperator{\msg}{msg}
\DeclareMathOperator{\moduli}{moduli}
%
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}


\begin{document}
    \lipsum[11]
\begingroup
\DefTblrTemplate{capcont}{default}{}
\SetTblrStyle{contfoot}{font=\small\sffamily\itshape}
\begin{longtblr}[
    entry=none,     % <---
    label=none  ]
                {vlines,
                 colspec = { Q[l, mode=math] X[l] },
                 row{1}  = {font=\bfseries, mode=text},
                 rowsep  = 1pt,
                 rowhead = 1
                 }
    \toprule
Symbol          &   Definition                          \\
    \midrule
X               & Unwatermarked dataset                 \\
X'              & A watermarked dataset                 \\
\overline{X}    & The mean of the dataset $X$           \\
\overline{X'}   & The mean of the dataset $X'$          \\
G               & Pseudorandom number generator         \\
K               & The watermark                         \\
n               & The length of the dataset, and the watermark sequence         \\
SH_{key}        & A secret key used to shuffle the data                         \\
S               & The sequence generated via the pseudorandom number generator  \\
\hat{X}         & A copy of the data expected to be watermarked                 \\
S_{X}^{2}       & Variance for the dataset $X$          \\
S_{X'}^{2}      & Variance for the dataset $X$          \\
s_{i}           & Individual element in the sequence $S$ at the position $i$    \\
P               & The probability for a variable        \\
T               & Sequence follows a Gaussian $N(0,1)$ distribution             \\
t_{i}           & Individual element in the sequence $T$ at the position $i$    \\
M               & A secret value kept with the watermarker in the watermarking algorithm 2  \\
\epsilon        & Determines the error in the results of the watermarked dataset $X'$       \\
a, b, \lambda   & Parameters used to watermark the dataset $X$ using the watermarking algorithm 2 \\
x_{i}           & Individual element in the sequence $X$ at the position i      \\
x_{i}'  & Individual element in the sequence $X'$ at the position i     \\
\abs{t_{i}}     & Absolute value of $t_{i}$              \\
\hat{M}         & The verified secret value in the watermarked data $\hat{X}$   \\
E(\cdot)        & Encryption function                   \\
%\mathcal{O} & Time complexity \\
\overline{n}    & Represents the RLWE dimension         \\
q               & The ciphertext modulus                \\
X''             & Watermarked and obfuscated dataset    \\
\obf_{\key}      & Secret key used to obfuscate and deobfuscate data                 \\
\widehat{x}_{i} & Individual element in the sequence $\widehat{X}$ at the position $i$  \\
C               & A column of data                      \\
r               & The number of ones in a binary sequence                           \\
\bob_{\rk}      & Bob's repacking key                   \\
\bob_{SwK}      & Bob's key for the key-switch function \\
\bob_{pk}       & Bob's public key                      \\
\bob_{EK}       & Bob's evaluation key                  \\
\bob_{RotK}     & Bob's rotation key                    \\
\bob_{RelK}     & Bob's relinearization key             \\
\bob_{s}        & Bob's secret key                      \\
\mathbf{g}_{\digit} & The digit decomposition gadget    \\
\mathbf{g}_{\rns}   & The RNS decomposition gadget      \\
\Delta          & The scaling factor                    \\
\underline{n}   & Represents the LWE dimension for the input into the look-up table \\
n'              & Represents the LWE dimension for the output of the look-up table  \\
\Delta          & The scaling factor                    \\
B_{ks}          & The digit decomposition base          \\
h               & The hamming weight                    \\
\msg            & Indicates the message interval that the look-up table can process \\
\s2c            & Slot to coefficient function          \\
\moduli         & Represents the multiplicative depth for a ciphertext \\
\unit{\micro\second}    & Microseconds                  \\
    \bottomrule
\end{longtblr}
\end{document}

在此处输入图片描述

相关内容