Consejos sobre el uso de un paquete independiente con entorno tabular

Consejos sobre el uso de un paquete independiente con entorno tabular

tabular¿Por qué se trunca el contenido prescrito por el código contenido en el entorno (extremo derecho) cuando se llama usando la standaloneclase de documento configurada en el mwe a continuación?

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

Probablemente se trate de un caso de configuración inadecuada standalonepor mi parte.

Respuesta1

Para eliminar el truncamiento, eliminé el centerentorno y algunas opciones de clase en el siguiente ejemplo. Para eliminar la advertencia del cuadro insuficientemente lleno, también cambié el ancho de la minipágina de 1cma \linewidth. Con esta configuración, las minipáginas heredan automáticamente el ancho de la pcolumna de tipo en la que se utilizan.

\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 componer fórmulas químicas, recomendaría el uso de mhchem(o chemformula) y para las unidades que usaría sinuintx. He incluido ambos en el siguiente ejemplo:

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

Respuesta2

Puedes utilizar paquetes especializados, además de no utilizar previewy simplemente componer la tabla. En lugar de un minipagedonde es necesario adivinar el ancho, use un anidado 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}

ingrese la descripción de la imagen aquí

Respuesta3

@leandriis ligeramente modificadorespuesta:

ingrese la descripción de la imagen aquí

\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 señalé en mi comentario a continuación, la causa de su problema es el uso de una vista previa centerdel entorno Tightpage siunitx makecell` para encabezados de columna más compactos.. Also options optionsandare superfluous. The packageis also exploited for numbers in your table, and

información relacionada