如何将 \includegraphics 与 booktabs 一起使用?

如何将 \includegraphics 与 booktabs 一起使用?

我正在为我的学生制作一份关于 14 个布拉维点阵的参考文档。我已经让这张表工作了,但它很乱。有人对如何清理它有什么建议吗?(我已将图表添加到此帖子中,以便大家可以自行编译代码以了解我的意思。有一天,当我有时间时,我会用 tikz 制作这些,但今年不会。)

\documentclass[11pt]{article} 
\usepackage[utf8]{inputenc} 
\usepackage{geometry}
\geometry{a4paper} 

\usepackage{graphicx} 
\usepackage{booktabs} 
\usepackage{array} 
\usepackage{multirow}
\usepackage{amssymb}
\usepackage{amsmath}


\begin{document}

\begin{table}\centering
\begin{tabular}{|c|c|c|cccc|c|} \hline
    &   &   & \multicolumn{4}{c|}{variants}             
                            &   \\ 
%Lattice \#     
    &   
        & system        
            & p     &bo-c           
                    & fc  & ba-c                                    
                            &   \\ \hline
1   & \multirow{3}*{$\alpha=\beta=\gamma=90^\circ; a= b= c$}
         & \multirow{3}*{cubic}
            &{\Huge \checkmark }    
                &   &   &   &\multirow{3}*{\includegraphics[width=20mm]{cubic.png}}
                                \\ 
2   & 
        &      &    & {\Huge \checkmark }
                    &   &      &    \\
3   &   &   &   &   & {\Huge \checkmark }
                        &       &   \\ \hline
4   & \multirow{4}*{$\alpha=\beta=\gamma=90^\circ; a=b\neq c$}
        & \multirow{4}*{tetragonal }
            & {\Huge \checkmark }   
                &   &   &      &\multirow{4}*{\includegraphics[width=20mm]{tetragonal.png}  }
                                \\
5   &   &       &   & {\Huge \checkmark }   
                    &   &   &   \\
6   &   &       &   &   & {\Huge \checkmark }
                        &   &   \\
7   &   &       &   &   &   & {\Huge \checkmark }
                            &   \\ \hline
8   &$\alpha=\beta=90^\circ; \gamma=120^\circ; a=b\neq c$   
        & hexagonal     
            &{\Huge \checkmark }    
                &      &        &       & \includegraphics[width=25mm]{hexagonal.png} 
                                \\ \hline
9   &\multirow{5}*{$\alpha=\beta=90^\circ;  \gamma=120^\circ; a=b\neq c$}
    & \multirow{5}*{trigonal }      
            & {\Huge \checkmark }   
                &       &   &      & \multirow{5}*{ \includegraphics[width=20mm]{trigonal.png}}
                                \\                              
\multirow{4}*{10}   
    &   &   &   &   &   & \multirow{4}*{{\Huge \checkmark } }
                            &   \\ 
    &   &   &   &   &   &   &   \\
    &   &   &   &   &   &   &   \\                              
    &   &   &   &   &   &   &   \\ \hline
11  & \multirow{4}*{$\alpha=\beta=\gamma=90^\circ; a\neq b\neq c$}
        & \multirow{4}*{orthorhombic }
            &{\Huge \checkmark }    
                &   &   &   &  \multirow{4}*{\includegraphics[width=20mm]{orthorhombic.png} }
                                \\
\multirow{4}*{12}   
    &   &   &   & \multirow{4}*{{\Huge \checkmark } }
                &   &   &       \\ 
    &   &   &   &   &   &   &   \\
    &   &   &   &   &   &   &   \\ 
    &   &   &   &   &   &   &   \\  \hline
13  & $ \alpha=\gamma=90^\circ; \hfill \beta>90^\circ ; a\neq b \neq c$ 
        & monoclinic   
            &{\Huge \checkmark }    
                &   &   &   &    \includegraphics[width=20mm]{monoclinic.png}      
                                 \\ \hline
14
    & $\alpha \neq \beta \neq \gamma;  a\neq b\neq c$   
        & triclinic    
            &{\Huge \checkmark }    
                &   &   &   &   \includegraphics[width=20mm]{triclinic.png}
                                \\ \hline                           
\end{tabular}\end{table}

\end{document}

立方体 六角形 单斜 正交晶系 四方的 三斜 三角形的

答案1

这并不比您的基础表格更难输入\multirow。这个想法是使用内部表格来表示多个列,利用正常大小的对象将使表格行自动对齐的事实。

\documentclass[11pt]{article} 
\usepackage[utf8]{inputenc} 
\usepackage{geometry}
\geometry{a4paper} 

\usepackage{graphicx} 
\usepackage{amssymb}
\usepackage{amsmath}

\newcommand{\cincludegraphics}[2][]{%
  \sbox0{\includegraphics[#1]{#2}}%
  \ht0=\dimexpr\ht0+3pt\relax
  \dp0=3pt
  \splitcell{\box0}%
}
\newcommand{\splitcell}[1]{%
  \begin{tabular}{@{}c@{}}#1\end{tabular}%
}
\newcommand{\bigcheckmark}{\smash{\Large\checkmark}}

\begin{document}

\begin{table}
\centering\small
\addtolength{\tabcolsep}{-1.4pt}

\begin{tabular}{|c|c|c|cccc|c|}
\hline
\# & & system & \multicolumn{4}{c|}{variants} & \\ 
& & & p & bo-c & fc  & ba-c & \\
\hline
\splitcell{1 \\ 2 \\ 3} &
$\alpha=\beta=\gamma=90^\circ; a= b= c$ &
cubic &
\splitcell{\bigcheckmark \\ \mbox{} \\ \mbox{}} &
\splitcell{\mbox{} \\ \bigcheckmark \\ \mbox{}} &
\splitcell{\mbox{} \\ \mbox{} \\ \bigcheckmark} &
&
\cincludegraphics[height=3\normalbaselineskip]{cubic.png} \\
\hline
\splitcell{%
  \mbox{} \\[-0.7\normalbaselineskip]
  4 \\ 5 \\ 6 \\ 7
  \\[-0.7\normalbaselineskip] \mbox{}%
} &
$\alpha=\beta=\gamma=90^\circ; a=b\neq c$ &
tetragonal &
\splitcell{%
  \mbox{}\\[-0.7\normalbaselineskip]
  \bigcheckmark \\ \mbox{} \\ \mbox{} \\ \mbox{}
  \\[-0.7\normalbaselineskip] \mbox{}%
} &
\splitcell{%
  \mbox{}\\[-0.7\normalbaselineskip]
  \mbox{} \\ \bigcheckmark \\ \mbox{} \\ \mbox{}
  \\[-0.7\normalbaselineskip] \mbox{}%
} &
\splitcell{%
  \mbox{}\\[-0.7\normalbaselineskip]
  \mbox{} \\ \mbox{} \\ \bigcheckmark \\ \mbox{}
  \\[-0.7\normalbaselineskip] \mbox{}%
} &
\splitcell{%
  \mbox{}\\[-0.7\normalbaselineskip]
  \mbox{} \\ \mbox{} \\ \mbox{} \\ \bigcheckmark
  \\[-0.7\normalbaselineskip] \mbox{}%
} &
\cincludegraphics[height=3\normalbaselineskip]{tetragonal.png} \\
\hline
8 &
$\alpha=\beta=90^\circ; \gamma=120^\circ; a=b\neq c$ &
hexagonal &
\bigcheckmark & & & &
\cincludegraphics[height=3\normalbaselineskip]{hexagonal.png} \\
\hline
\splitcell{9 \\[-0.5\normalbaselineskip] \mbox{} \\ 10} &
$\alpha=\beta=90^\circ; \gamma=120^\circ; a=b\neq c$ &
trigonal &
\splitcell{\bigcheckmark \\[-0.5\normalbaselineskip] \mbox{} \\ \mbox{}} & & &
\splitcell{\mbox{} \\[-0.5\normalbaselineskip] \mbox{} \\ \bigcheckmark} &
\cincludegraphics[height=3\normalbaselineskip]{trigonal.png} \\
\hline
\splitcell{11 \\[-0.5\normalbaselineskip] \mbox{} \\ 12} &
$\alpha=\beta=\gamma=90^\circ; a\neq b\neq c$ &
orthorhombic &
\splitcell{\bigcheckmark \\[-0.5\normalbaselineskip] \mbox{} \\ \mbox{}} &
\splitcell{\mbox{} \\[-0.5\normalbaselineskip] \mbox{} \\ \bigcheckmark} & & &
\cincludegraphics[height=3\normalbaselineskip]{orthorhombic.png} \\
\hline
13 &
$\alpha=\gamma=90^\circ; \beta>90^\circ ; a\neq b \neq c$ &
monoclinic &
\bigcheckmark & & & &
\cincludegraphics[height=3\normalbaselineskip]{monoclinic.png} \\
\hline
14 &
$\alpha \neq \beta \neq \gamma;  a\neq b\neq c$ &
triclinic &
\bigcheckmark & & & &
\cincludegraphics[height=3\normalbaselineskip]{triclinic.png} \\
\hline
\end{tabular}

\end{table}

\end{document}

在此处输入图片描述

booktabs

\documentclass[11pt]{article} 
\usepackage[utf8]{inputenc} 
\usepackage{geometry}
\geometry{a4paper} 

\usepackage{graphicx} 
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{booktabs}

\newcommand{\cincludegraphics}[2][]{%
  \sbox0{\includegraphics[#1]{#2}}%
  \ht0=\dimexpr\ht0+3pt\relax
  \dp0=3pt
  \splitcell{\box0}%
}
\newcommand{\splitcell}[1]{%
  \begin{tabular}{@{}c@{}}#1\end{tabular}%
}
\newcommand{\bigcheckmark}{\smash{\Large\checkmark}}

\begin{document}

\begin{table}
\centering\small

\begin{tabular}{@{}cccccccc@{}}
\toprule
\# & & system & \multicolumn{4}{c}{variants} & \\
\cmidrule(lr){4-7}
& & & p & bo-c & fc  & ba-c & \\
\midrule
\splitcell{1 \\ 2 \\ 3} &
$\alpha=\beta=\gamma=90^\circ; a= b= c$ &
cubic &
\splitcell{\bigcheckmark \\ \mbox{} \\ \mbox{}} &
\splitcell{\mbox{} \\ \bigcheckmark \\ \mbox{}} &
\splitcell{\mbox{} \\ \mbox{} \\ \bigcheckmark} &
&
\cincludegraphics[height=3\normalbaselineskip]{cubic.png} \\
\midrule
\splitcell{%
  \mbox{} \\[-0.7\normalbaselineskip]
  4 \\ 5 \\ 6 \\ 7
  \\[-0.7\normalbaselineskip] \mbox{}%
} &
$\alpha=\beta=\gamma=90^\circ; a=b\neq c$ &
tetragonal &
\splitcell{%
  \mbox{}\\[-0.7\normalbaselineskip]
  \bigcheckmark \\ \mbox{} \\ \mbox{} \\ \mbox{}
  \\[-0.7\normalbaselineskip] \mbox{}%
} &
\splitcell{%
  \mbox{}\\[-0.7\normalbaselineskip]
  \mbox{} \\ \bigcheckmark \\ \mbox{} \\ \mbox{}
  \\[-0.7\normalbaselineskip] \mbox{}%
} &
\splitcell{%
  \mbox{}\\[-0.7\normalbaselineskip]
  \mbox{} \\ \mbox{} \\ \bigcheckmark \\ \mbox{}
  \\[-0.7\normalbaselineskip] \mbox{}%
} &
\splitcell{%
  \mbox{}\\[-0.7\normalbaselineskip]
  \mbox{} \\ \mbox{} \\ \mbox{} \\ \bigcheckmark
  \\[-0.7\normalbaselineskip] \mbox{}%
} &
\cincludegraphics[height=3\normalbaselineskip]{tetragonal.png} \\
\midrule
8 &
$\alpha=\beta=90^\circ; \gamma=120^\circ; a=b\neq c$ &
hexagonal &
\bigcheckmark & & & &
\cincludegraphics[height=3\normalbaselineskip]{hexagonal.png} \\
\midrule
\splitcell{9 \\[-0.5\normalbaselineskip] \mbox{} \\ 10} &
$\alpha=\beta=90^\circ; \gamma=120^\circ; a=b\neq c$ &
trigonal &
\splitcell{\bigcheckmark \\[-0.5\normalbaselineskip] \mbox{} \\ \mbox{}} & & &
\splitcell{\mbox{} \\[-0.5\normalbaselineskip] \mbox{} \\ \bigcheckmark} &
\cincludegraphics[height=3\normalbaselineskip]{trigonal.png} \\
\midrule
\splitcell{11 \\[-0.5\normalbaselineskip] \mbox{} \\ 12} &
$\alpha=\beta=\gamma=90^\circ; a\neq b\neq c$ &
orthorhombic &
\splitcell{\bigcheckmark \\[-0.5\normalbaselineskip] \mbox{} \\ \mbox{}} &
\splitcell{\mbox{} \\[-0.5\normalbaselineskip] \mbox{} \\ \bigcheckmark} & & &
\cincludegraphics[height=3\normalbaselineskip]{orthorhombic.png} \\
\midrule
13 &
$\alpha=\gamma=90^\circ; \beta>90^\circ ; a\neq b \neq c$ &
monoclinic &
\bigcheckmark & & & &
\cincludegraphics[height=3\normalbaselineskip]{monoclinic.png} \\
\midrule
14 &
$\alpha \neq \beta \neq \gamma;  a\neq b\neq c$ &
triclinic &
\bigcheckmark & & & &
\cincludegraphics[height=3\normalbaselineskip]{triclinic.png} \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

在此处输入图片描述

相关内容