將表格列與特定數學符號對齊

將表格列與特定數學符號對齊

我確實有一個longtabu\newglossarystyle它最初是in 的一部分glossaries符號列表,但我為 MWE 提取了它。第一列顯示數學運算符,第二列顯示其描述。正如您所看到的,第一列看起來相當混亂。如果第一列位於括號的中心,那就更好了。有可能自動實現這一點嗎?

在此輸入影像描述

我已經嘗試在括號之前和之後使用\hphantoms,但這會導致大量的手動工作,並且在全域範圍內無效。要在小數點上對齊列或其他符號dcolumn包,但我無法得到我想要的結果。我嘗試的最後一件事是簡單地放在定義\begin{longtabu} to \linewidth {r@{${}\left(\phantom{a}\right){}$}lX}中並在我不需要括號的地方longtabu使用。multicolumn但對齊方式也不正確。

是否有一種自動方法可以實現括號上第一列的對齊?


原始MWE

\documentclass{article}

\usepackage{longtable}
\usepackage{tabu}

\newcommand*\dif{\mathop{}\!\mathrm{d}}

\begin{document}

\begingroup
\renewcommand{\arraystretch}{1.4}
\begin{longtabu} to \linewidth {cX}
Symbol                                      & Description   \tabularnewline
$\bar{\left(\phantom{a}\right)}$            & Operator 1    \tabularnewline
$\dif\left(\phantom{a}\right)$              & Operator 2    \tabularnewline
$\dot{\left(\phantom{a}\right)}$            & Operator 3    \tabularnewline
$\left(\phantom{a}\right)_{,x}$             & Operator 4    \tabularnewline
$\hat{\left(\phantom{a}\right)}$            & Operator 5    \tabularnewline
$\left(\phantom{a}\right)^{-1}$             & Operator 6    \tabularnewline
$\partial\left(\phantom{a}\right)$          & Operator 7    \tabularnewline
$\left(\phantom{a}\right)^T$                & Operator 8    \tabularnewline
\end{longtabu}
\endgroup

\end{document}

嘗試1

多列的居中方向擾亂了這些線條。

\documentclass{article}

\usepackage{longtable}
\usepackage{tabu}

\newcommand*\dif{\mathop{}\!\mathrm{d}}

\begin{document}

\begingroup
\renewcommand{\arraystretch}{1.4}
\begin{longtabu} to \linewidth {r@{${}\left(\phantom{a}\right){}$}lX}
\multicolumn{2}{c}{Symbol}                           & Description   \tabularnewline
\multicolumn{2}{c}{$\bar{\left(\phantom{a}\right)}$} & Operator 1    \tabularnewline
$\dif$                                              && Operator 2    \tabularnewline
\multicolumn{2}{c}{$\dot{\left(\phantom{a}\right)}$} & Operator 3    \tabularnewline
&$_{,x}$                                             & Operator 4    \tabularnewline
\multicolumn{2}{c}{$\hat{\left(\phantom{a}\right)}$} & Operator 5    \tabularnewline
&$^{-1}$                                             & Operator 6    \tabularnewline
$\partial$                                          && Operator 7    \tabularnewline
&$^T$                                                & Operator 8    \tabularnewline
\end{longtabu}
\endgroup

\end{document}

嘗試2

基本上沒問題,但不適用於在定義\newglossaryentry中使用 this for 的上下文glossaries

\documentclass{article}

\usepackage{longtable}
\usepackage{tabu}

\newcommand*\dif{\mathop{}\!\mathrm{d}}

\begin{document}

\begingroup
\renewcommand{\arraystretch}{1.4}
\begin{longtabu} to \linewidth {r@{}c@{}lX}
\multicolumn{3}{c}{Symbol}                              & Description   \tabularnewline
           & $\bar{\left(\phantom{a}\right)}$ &         & Operator 1    \tabularnewline
$\dif$     & $\left(\phantom{a}\right)$       &         & Operator 2    \tabularnewline
           & $\dot{\left(\phantom{a}\right)}$ &         & Operator 3    \tabularnewline
           & $\left(\phantom{a}\right)$       & $_{,x}$ & Operator 4    \tabularnewline
           & $\hat{\left(\phantom{a}\right)}$ &         & Operator 5    \tabularnewline
           & $\left(\phantom{a}\right)$       & $^{-1}$ & Operator 6    \tabularnewline
$\partial$ & $\left(\phantom{a}\right)$       &         & Operator 7    \tabularnewline
           & $\left(\phantom{a}\right)$       & $^T$    & Operator 8    \tabularnewline
\end{longtabu}
\endgroup

\end{document}

在此輸入影像描述

我設法將這個方案應用到詞彙表中。但似乎有很多手工工作:

符號定義:

\newglossary[slg7]{operatorlist}{syi7}{syg7}{Operators}
% compile with: makeindex -s %S.ist -t %S.slg7 -o %S.syi7 %S.syg7

\newglossaryentry{symb:operator:bar}{%
  symbol      ={$\bar{\left(\phantom{a}\right)}$},%
  name        ={},%
  description ={Value in material coordinate system},%
  user1       ={},%
  user2       ={$\protect\bar{\protect\left(\protect\phantom{a}\protect\right)}$},%
  user3       ={},%
  type        =operatorlist,%
  sort        =olocalbar,%
}

\newglossaryentry{symb:operator:dif}{%
  symbol      ={$\dif\left(\phantom{a}\right)$},%
  name        ={},%
  description ={Differential operator},%
  user1       ={$\protect\dif$},%
  user2       ={$\protect\left(\protect\phantom{a}\protect\right)$},%
  user3       ={},%
  type        =operatorlist,%
  sort        =odifdifferential,%
}

\newglossaryentry{symb:operator:dx}{%
  symbol      ={$\left(\phantom{a}\right)_{,x}$},%
  name        ={},%
  description ={Spatial derivative with respect to coordinate $x$},%
  user1       ={},%
  user2       ={$\protect\left(\protect\phantom{a}\protect\right)$},%
  user3       ={$_{,x}$},%
  type        =operatorlist,%
  sort        =odifdx,%
}

glossaries風格:

\newglossarystyle{myoperatorstyle}{%
  \renewcommand*{\glsclearpage}{}%
  \renewenvironment{theglossary}%
    {%
      \begingroup%
      \renewcommand{\arraystretch}{1.4}%
      \begin{longtabu} to \linewidth {@{\ \;}r@{}c@{}lX}
    }%
    {%
      \end{longtabu}
      \endgroup
    }%
  % Header line
  \renewcommand*{\glossaryheader}{%
    \multicolumn{3}{@{}c}{\textbf{Symbol}} & \textbf{Description}%
    \tabularnewline%
    \tabularnewline%
    \endhead%
    \endfoot%
  }%
  % indicate what to do at the start of each logical group
  \renewcommand*{\glsgroupskip}{\tabularnewline}% What to do between groups
  % entry
  \renewcommand*{\glossentry}[1]{%
    \glsentryitem{##1}% Entry number if required
    \glsentryuseri{##1} &
    \glsentryuserii{##1} &
    \glsentryuseriii{##1} &
    \glossentrydesc{##1}
    \tabularnewline%
  }%
}

印刷術語表:

\printglossary[type=operatorlist,style=myoperatorstyle,nonumberlist]

答案1

你可以用包包來做eqparbox。為此,我定義了一個tpsymb命令(由三個部分組成的符號),其中包含3 個參數,正如人們很容易猜到的那樣:「前符號」、主符號(在整個文件中必須相同)和「後符號」。象徵'。將前置部分和後部分放在 中\eqmakebox,以便每個前置部分具有相同的寬度,對於後部分也是如此。

\documentclass{article}

\usepackage{longtable}
\usepackage{tabu}
\usepackage{ eqparbox}

    \newcommand\eqmathbox[2][M]{\eqmakebox[#1][l]{$\displaystyle#2$}}

\newcommand*\dif{\mathop{}\!\mathrm{d}}
\newcommand\tpsymb[3]{\eqmakebox[pre][r]{\ensuremath{#1}}\ensuremath{#2}\eqmakebox[post][l]{\ensuremath{#3}}}

%\newcommand\mysymbol
\begin{document}

\begingroup
\renewcommand{\arraystretch}{1.4}
\noindent
\begin{longtabu} to \linewidth {cX}
Symbol & Description \tabularnewline
\tpsymb{}{\bar{\left(\phantom{a}\right)}}{} & Operator 1 \tabularnewline
\tpsymb{\dif}{\left(\phantom{a}\right)}{} & Operator 2 \tabularnewline
\tpsymb{}{\dot{\left(\phantom{a}\right)}}{} & Operator 3 \tabularnewline
\tpsymb{}{\left(\phantom{a}\right)}{_{,x}} & Operator 4 \tabularnewline
\tpsymb{}{\hat{\left(\phantom{a}\right)}}{} & Operator 5 \tabularnewline
\tpsymb{}{\left(\phantom{a}\right)}{^{-1}} & Operator 6 \tabularnewline
\tpsymb{\partial}{\left(\phantom{a}\right)}{} & Operator 7 \tabularnewline
\tpsymb{}{\left(\phantom{a}\right)}{^T} & Operator 8 \tabularnewline
\end{longtabu}
\endgroup

\end{document} 

在此輸入影像描述

答案2

這主要是美學問題。即使數學符號位於字段的中心,它們也不會居中。您需要做的是決定您真正想要居中的內容,然後調整對齊點以使其居中。

在這種情況下,我居中$(a)$。這是透過測量最寬欄位 ( ) 的寬度Symbol和 的寬度$(a)$並將其新增\hspace*{\fixup}(您也可以使用\makebox[\fixup][r]{...})到左列來完成的。

\documentclass{article}

\usepackage{longtable}
\usepackage{tabu}

\newcommand*\dif{\mathop{}\!\mathrm{d}}

\newlength{\fixup}

\begin{document}

\settowidth{\dimen0}{Symbol}%
\settowidth{\dimen1}{$(a)$}%
\setlength{\fixup}{\dimexpr 0.5\dimen0 - 0.5\dimen1}%

\begingroup
\renewcommand{\arraystretch}{1.4}
\begin{longtabu} to \linewidth {r@{}lX}
\multicolumn{2}{c}{Symbol}              & Description   \tabularnewline
\hspace*{\fixup}% force alignment point to center $(a)$
&$\bar{(\phantom{a})}$    & Operator 1    \tabularnewline
$\dif$&$(\phantom{a})$                  & Operator 2    \tabularnewline
&$\dot{(\phantom{a})}$                  & Operator 3    \tabularnewline
&$(\phantom{a})_{,x}$                   & Operator 4    \tabularnewline
&$\hat{(\phantom{a})}$                  & Operator 5    \tabularnewline
&$(\phantom{a})^{-1}$                   & Operator 6    \tabularnewline
$\partial$&$(\phantom{a})$              & Operator 7    \tabularnewline
&$(\phantom{a})^T$                      & Operator 8    \tabularnewline
\end{longtabu}
\endgroup

\end{document}

示範

相關內容