Alinhe a coluna da tabela em um símbolo matemático específico

Alinhe a coluna da tabela em um símbolo matemático específico

eu tenho umlongtabuque originalmente faz parte de \newglossarystyleum glossarieslista de símbolos, mas extraí para o MWE. A primeira coluna mostra os operadores matemáticos e a segunda a sua descrição. Como você pode ver, a primeira coluna parece um tanto confusa. Seria muito melhor ter a primeira coluna centralizada nos colchetes. Existe a possibilidade de conseguir isso automaticamente?

insira a descrição da imagem aqui

Já tentei brincar com \hphantoms antes e depois dos colchetes, mas isso resulta em muito trabalho manual e não é válido globalmente. Para alinhar colunas na vírgula decimal ououtros símbolosexiste odcolumnpacote, mas não consegui o resultado que queria. A última coisa que tentei foi simplesmente colocar \begin{longtabu} to \linewidth {r@{${}\left(\phantom{a}\right){}$}lX}na longtabudefinição e usar multicolumnonde não quiser os colchetes. Mas o alinhamento também estava incorreto.

Existe uma maneira automatizada de conseguir o alinhamento da primeira coluna entre colchetes?


MWE original

\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}

Tentativa 1

A orientação centralizada das multicolunas bagunça essas linhas.

\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}

Tentativa 2

Basicamente tudo bem, mas não aplicável no contexto do uso de this for \newglossaryentryem uma glossariesdefinição.

\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}

insira a descrição da imagem aqui

Consegui aplicar esse esquema ao glossário. Mas parece muito trabalho manual:

Definição do símbolo:

\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,%
}

glossariesestilo:

\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%
  }%
}

imprimir glossário:

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

Responder1

Você pode fazer isso com o eqparboxpacote. Para isso, defino um tpsymbcomando (símbolo de três partes), com, como se pode facilmente adivinhar, 3 argumentos: um 'pré-símbolo', o símbolo principal (que deve ser o mesmo em todo o arquivo) e um 'pós-símbolo'. símbolo'. As pré e pós-partes são colocadas em um \eqmakebox, para que cada uma das pré-partes tenha a mesma largura, e da mesma forma para as pós-partes.

\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} 

insira a descrição da imagem aqui

Responder2

Isso é principalmente uma questão de estética. Mesmo que os símbolos matemáticos estejam centralizados no campo, eles nãoolharcentrado. O que você precisa fazer é decidir o que realmente deseja centralizar e, em seguida, ajustar o ponto de alinhamento para centralizá-lo.

Neste caso, eu centralizei $(a)$. Isso foi feito medindo a largura do campo mais largo ( Symbol) e a largura $(a)$e adicionando \hspace*{\fixup}(você também pode usar \makebox[\fixup][r]{...}) à coluna da esquerda.

\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}

demonstração

informação relacionada