![特定の数学記号に表の列を揃える](https://rvso.com/image/353020/%E7%89%B9%E5%AE%9A%E3%81%AE%E6%95%B0%E5%AD%A6%E8%A8%98%E5%8F%B7%E3%81%AB%E8%A1%A8%E3%81%AE%E5%88%97%E3%82%92%E6%8F%83%E3%81%88%E3%82%8B.png)
私はlongtabu
\newglossarystyle
これは もともとglossaries
シンボルのリストですが、MWE 用に抽出しました。最初の列には数学演算子が表示され、2 番目の列にはその説明が表示されます。ご覧のとおり、最初の列はかなり乱雑に見えます。最初の列を括弧の中央に配置すると、はるかに見栄えが良くなります。これを自動的に実現する可能性はありますか?
すでに括弧の前後のsをいじってみました\hphantom
が、これは手作業が多くなり、全体的に有効ではありません。列を小数点またはその他の記号そこには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 を使用するコンテキストには適用されません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}