我在表格的单元格内插入了几张图片,但是单元格的高度并没有重新调整,而是图形与一些水平线重叠,我不知道如何解决这个问题。
我的序言是:
\documentclass[12pt]{article}
\usepackage[letterpaper, left=2.8cm, right=2.8cm, top=2.5cm, bottom=2.5cm]{geometry}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[document]{ragged2e}
\usepackage[usenames,dvipsnames,svgnames,table, xcdraw]{xcolor}
\usepackage{multirow}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{tabularx}
这是表格的代码:
\begin{table}[H]
\caption{Peligrosidad de los compuestos empleados}
\label{tab:pe}
\centering
\begin{tabular}{>{\centering\arraybackslash}m{2cm} >{\arraybackslash}c }
\hline
\textbf{Compuesto} & \textbf{Peligrosidad} \\
\hline \hline
Aceite de Girasol & Ninguna conforme al Reglamento no 1272/2008/CE. \\
\hline
NaOH & \includegraphics[scale=0.8]{Screenshot_2.png} \\
\hline
EtOH & \includegraphics[scale=0.8]{1.png} \\
\hline
Jabón & Ninguna conforme al Reglamento no 1272/2008/CE. \\
\hline
Glicerina & \includegraphics[scale=0.8]{Glicerol.png}
\\
\hline
\end{tabular}
\end{table}
答案1
如果此代码对您来说足够好,可能是@StevenB.Segletes 的答案这里就是您所寻找的...
\documentclass{article}
\usepackage{array}
\usepackage{float}
\usepackage{graphicx}
\usepackage{verbatimbox}
\let\oldincludegraphics\includegraphics
\renewcommand\includegraphics[2][]{\addvbuffer[3pt 0pt]{\oldincludegraphics[#1]{#2}}}
\begin{document}
\begin{table}[H]
\caption{Peligrosidad de los compuestos empleados}
\label{tab:pe}
\centering
\begin{tabular}{>{\centering\arraybackslash}m{2cm} >{\centering\arraybackslash} m{\dimexpr\linewidth-3cm\relax} }
\hline
\textbf{Compuesto} & \textbf{Peligrosidad} \\
\hline \hline
Aceite de Girasol & Ninguna conforme al Reglamento no 1272/2008/CE. \\
\hline
NaOH & \includegraphics[scale=0.8]{Screenshot_2.png} \\
\hline
EtOH & \includegraphics[scale=0.8]{1.png} \\
\hline
Jabón & Ninguna conforme al Reglamento no 1272/2008/CE. \\
\hline
Glicerina & \includegraphics[scale=0.8]{Glicerol.png}
\\
\hline
\end{tabular}
\end{table}
\end{document}