Conselhos sobre o uso de pacote independente com ambiente tabular

Conselhos sobre o uso de pacote independente com ambiente tabular

Por que o conteúdo prescrito pelo código contido no tabularambiente é truncado (extrema direita) quando chamado usando a standaloneclasse 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 standaloneminha parte.

Responder1

Para remover o truncamento, removi o centerambiente, 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 1cmpara \linewidth. Com esta configuração, as minipáginas herdam automaticamente a largura da pcoluna 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 previewe simplesmente compor a tabela. Em vez de minipageonde 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}

insira a descrição da imagem aqui

Responder3

Ligeiramente modificado @leandriisresponder:

insira a descrição da imagem aqui

\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 centeranvironment . Also options optionspreview andtightpage are superfluous. The packagesiunitx is also exploited for numbers in your table, andmakecell` para cabeçalhos de coluna mais compactos.

informação relacionada