特定の数学記号に表の列を揃える

特定の数学記号に表の列を揃える

私はlongtabu\newglossarystyleこれは もともとglossariesシンボルのリストですが、MWE 用に抽出しました。最初の列には数学演算子が表示され、2 番目の列にはその説明が表示されます。ご覧のとおり、最初の列はかなり乱雑に見えます。最初の列を括弧の中央に配置すると、はるかに見栄えが良くなります。これを自動的に実現する可能性はありますか?

ここに画像の説明を入力してください

すでに括弧の前後のsをいじってみました\hphantomが、これは手作業が多くなり、全体的に有効ではありません。列を小数点またはその他の記号そこにはdcolumnパッケージを作成しましたが、期待した結果は得られませんでした。最後に試したのは、定義\begin{longtabu} to \linewidth {r@{${}\left(\phantom{a}\right){}$}lX}内に単に配置しlongtabumulticolumn括弧が不要な場所で使用するというものでした。しかし、配置も間違っていました。

括弧の最初の列の位置合わせを自動的に行う方法はありますか?


オリジナル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 を使用するコンテキストには適用されません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 つの部分から成るシンボル) を定義します。簡単に推測できるように、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}

デモ

関連情報