![Alinhamento incorreto em ambiente tabular ao usar a opção de tabela xcolor](https://rvso.com/image/335467/Alinhamento%20incorreto%20em%20ambiente%20tabular%20ao%20usar%20a%20op%C3%A7%C3%A3o%20de%20tabela%20xcolor.png)
Me deparei com um comportamento estranho ao carregar xcolor=table
a opção que afeta o alinhamento adequado no ambiente tabular.
A saída deste MWE
\documentclass{beamer}
\usepackage{siunitx,booktabs,multirow}
\begin{document}
\begin{frame}
\centering
\begin{tabular}{@{}l|ccc@{}}
\toprule
\multirow{2}{*}{\huge Parameters} & \multicolumn{3}{c}{Levels}\\
\cmidrule{2-4}
& 1 & 2 & 3 \\
\midrule
Power \hfill \si{\W} & 100 & 200 & 300 \\
\bottomrule
\end{tabular}
\end{frame}
\end{document}
é
Porém, ao usar a opção \documentclass[xcolor=table]{beamer}
, obtive a saída assim com alinhamento incorreto na primeira célula da última linha.
Como posso obter o alinhamento adequado ao carregar esta opção xcolor=table
?
Responder1
Use duas colunas em vez de uma:
\documentclass[xcolor=table]{beamer}
\usepackage{siunitx,booktabs,multirow}
\begin{document}
\begin{frame}
\centering
\begin{tabular}{@{}lrccc@{}}
\toprule
\multicolumn{2}{@{}c}{\multirow{2}{*}{\huge Parameters}} & \multicolumn{3}{c}{Levels}\\
\cmidrule{3-5}
& & 1 & 2 & 3 \\
\midrule
Power & \si{\W} & 100 & 200 & 300 \\
\bottomrule
\end{tabular}
\bigskip
\begin{tabular}{@{}lrccc@{}}
\toprule
\multicolumn{2}{@{}c}{Parameters} & \multicolumn{3}{c}{Levels}\\
\cmidrule{3-5}
& & 1 & 2 & 3 \\
\midrule
Power & \si{\W} & 100 & 200 & 300 \\
\bottomrule
\end{tabular}
\end{frame}
\end{document}
Sugiro que você considere a segunda tabela, sem o \huge
rótulo gigantesco.
Alternativamente, em seu código, escreva
Power\hspace{0pt plus 1filll}\si{W}
A razão TeXnical é que colortbl
(carregado com a table
opção to xcolor
) realiza o alinhamento à esquerda com, \hfill
em vez de com, \hfil
o código principal. Portanto, você precisa de uma cola infinita de ordem superior para empurrar o objeto para a margem direita.