![Выровнять столбец таблицы по определенному математическому символу](https://rvso.com/image/353020/%D0%92%D1%8B%D1%80%D0%BE%D0%B2%D0%BD%D1%8F%D1%82%D1%8C%20%D1%81%D1%82%D0%BE%D0%BB%D0%B1%D0%B5%D1%86%20%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%86%D1%8B%20%D0%BF%D0%BE%20%D0%BE%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D0%B5%D0%BD%D0%BD%D0%BE%D0%BC%D1%83%20%D0%BC%D0%B0%D1%82%D0%B5%D0%BC%D0%B0%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%BE%D0%BC%D1%83%20%D1%81%D0%B8%D0%BC%D0%B2%D0%BE%D0%BB%D1%83.png)
У меня естьlongtabu
\newglossarystyle
который изначально является частьюglossaries
список символов, но я извлек его для MWE. В первом столбце показаны математические операторы, а во втором — их описание. Как видите, первый столбец выглядит довольно беспорядочно. Было бы гораздо лучше, если бы первый столбец был отцентрирован по скобкам. Есть ли возможность добиться этого автоматически?
Я уже пробовал играть с \hphantom
s до и после скобок, но это приводит к большому количеству ручной работы и не является глобально допустимым. Чтобы выровнять столбцы по десятичной точке илидругие символыЗдесьdcolumn
package, но я не смог получить желаемый результат. Последнее, что я пробовал, это просто поместить \begin{longtabu} to \linewidth {r@{${}\left(\phantom{a}\right){}$}lX}
определение longtabu
и использовать multicolumn
везде, где мне не нужны скобки. Но выравнивание также было неправильным.
Существует ли автоматизированный способ выравнивания первого столбца на кронштейнах?
Оригинальный МВЭ
\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
в 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 аргументами: 'pre-symbol', основной символ (который должен быть одинаковым во всем файле) и 'post-symbol'. Pre- и post-части помещаются в \eqmakebox
, так что каждая из pre-частей имеет одинаковую ширину, и аналогично для post-частей.
\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}