
Por que o conteúdo prescrito pelo código contido no tabular
ambiente é truncado (extrema direita) quando chamado usando a standalone
classe de documento configurada no mwe abaixo?
\documentclass[preview,border=7pt,active,tightpage]{standalone}
\usepackage{booktabs}
\usepackage{chemfig}
\usepackage{filecontents}
\usepackage[scaled]{helvet}
\begin{filecontents}{methane.tex}
\chemfig{
H% 2
-[:210]% 1
(
-[:210]H% 3
)
(
-[:300]H% 5
)
-[:120]H% 4
}
\end{filecontents}
% sans serif font
\renewcommand\familydefault{\sfdefault}
% define formula
\def\methane{\mathrm{CH_{4}}}
\begin{document}
\begin{center}
\begin{tabular}[]{lp{3.5cm}ccc}
\toprule
\textbf{Formula} & \textbf{Structure} & \textbf{Molar mass} (g mol$^{-1}$) & \textbf{Melting point} ($^{\circ}\mathrm{C}$) & \textbf{Boiling point} ($^{\circ}\mathrm{C}$) \\
\midrule%
$\methane$ & \begin{minipage}[]{1cm} \input{methane.tex} \end{minipage} & 16.043 & -182.50 & -161.50 \\ [2mm]
\bottomrule
\end{tabular}
\end{center}
\end{document}
Este é provavelmente um caso de configuração inadequada da standalone
minha parte.
Responder1
Para remover o truncamento, removi o center
ambiente, bem como algumas opções de classe no exemplo a seguir. Para remover o aviso de caixa insuficientemente cheia, também alterei a largura da minipágina de 1cm
para \linewidth
. Com esta configuração, as minipáginas herdam automaticamente a largura da p
coluna tpe em que são usadas.
\documentclass[border=7pt]{standalone}
\usepackage{booktabs}
\usepackage{chemfig}
\usepackage{filecontents}
\usepackage[scaled]{helvet}
\begin{filecontents}{methane.tex}
\chemfig{
H% 2
-[:210]% 1
(
-[:210]H% 3
)
(
-[:300]H% 5
)
-[:120]H% 4
}
\end{filecontents}
% sans serif font
\renewcommand\familydefault{\sfdefault}
% define formula
\def\methane{\mathrm{CH_{4}}}
\begin{document}
\begin{tabular}[]{lp{3.5cm}ccc}
\toprule
\textbf{Formula} & \textbf{Structure} & \textbf{Molar mass} (g mol$^{-1}$) & \textbf{Melting point} ($^{\circ}\mathrm{C}$) & \textbf{Boiling point} ($^{\circ}\mathrm{C}$) \\
\midrule%
$\methane$ & \begin{minipage}[]{\linewidth} \input{methane.tex} \end{minipage} & 16.043 & -182.50 & -161.50 \\ [2mm]
\bottomrule
\end{tabular}
\end{document}
Para compor fórmulas químicas, recomendo o uso de mhchem
(ou chemformula
) e para as unidades que usaria sinuintx
. Eu incluí ambos no exemplo a seguir:
\documentclass[border=7pt]{standalone}
\usepackage{booktabs}
\usepackage{chemfig}
\usepackage{filecontents}
\usepackage[scaled]{helvet}
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\begin{filecontents}{methane.tex}
\chemfig{
H% 2
-[:210]% 1
(
-[:210]H% 3
)
(
-[:300]H% 5
)
-[:120]H% 4
}
\end{filecontents}
% sans serif font
\renewcommand\familydefault{\sfdefault}
% define formula
\def\methane{\ce{CH4}}
\begin{document}
\begin{tabular}[]{lp{3.5cm}ccc}
\toprule
\textbf{Formula} & \textbf{Structure} & \textbf{Molar mass} (\si{\gram\per\mole}) & \textbf{Melting point} (\si{\celsius}) & \textbf{Boiling point} (\si{\celsius}) \\
\midrule%
$\methane$ & \begin{minipage}[]{\linewidth} \input{methane.tex} \end{minipage} & 16.043 & -182.50 & -161.50 \\ [2mm]
\bottomrule
\end{tabular}
\end{document}
Responder2
Você pode usar pacotes especializados, além de não usar preview
e simplesmente compor a tabela. Em vez de minipage
onde a largura precisa ser adivinhada, use um nested tabular
.
\documentclass[margin=4]{standalone}
\usepackage{booktabs}
\usepackage{chemfig,chemformula,siunitx}
\usepackage{filecontents}
\usepackage[scaled]{helvet}
\begin{filecontents}{methane.tex}
\chemfig{
H% 2
-[:210]% 1
(
-[:210]H% 3
)
(
-[:300]H% 5
)
-[:120]H% 4
}
\end{filecontents}
% sans serif font
\renewcommand\familydefault{\sfdefault}
\begin{document}
\begin{tabular}{
l
c
S[table-format=2.3]
S[table-format=-3.2]
S[table-format=-3.2]
}
\toprule
\textbf{Formula} &
\textbf{Structure} &
{\textbf{Molar mass} (\si{\gram\per\mol})} &
{\textbf{Melting point} (\si{\celsius})} &
{\textbf{Boiling point} (\si{\celsius})} \\
\midrule
\ch{CH4} & \begin{tabular}{@{}c@{}}\input{methane.tex}\end{tabular} & 16.043 & -182.50 & -161.50 \\
\bottomrule
\end{tabular}
\end{document}
Responder3
Ligeiramente modificado @leandriisresponder:
\documentclass[border=7pt]{standalone}
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault}
\usepackage{booktabs, makecell}
\renewcommand\theadfont{\small\bfseries}
\renewcommand\theadgape{}
\setcellgapes{3pt}
\makegapedcells
\usepackage{chemfig}
\newcommand\methane{\chemfig{H -[:0]C (-[:90]H)(-[:270]H)(-[:0]H)}}
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\begin{document}
\setchemfig{atom sep=2em}
\begin{tabular}[]{l c SSS}
\toprule
\thead{Formula}
& \thead{Structure}
& {\thead{Molar mass\\ (\si{\gram\per\mole})}}
& {\thead{Melting point\\ (\si{\celsius})}}
& {\thead{Boiling point\\ (\si{\celsius})}} \\
\midrule
\ce{CH4} & \methane
& 16.043 & -182.50 & -161.50 \\
\bottomrule
\end{tabular}
\end{document}
Como observei em meu comentário abaixo, a causa do seu problema é usada center
anvironment . Also options options
preview and
tightpage are superfluous. The package
siunitx is also exploited for numbers in your table, and
makecell` para cabeçalhos de coluna mais compactos.