Making table cells independent of one another
In effect, you want to align a picture at top in a table. There has been a number of discussions on this, A, B, C, and D are only a few them.
Anyway, actually, your pictures created by \chemfig
have their base-lines set at the bottom of the picture. This makes them placed in that unwanted manner.
You could use the \smash
command to make your box zero height and depth. But that would have an adverse effect like this.
Another option could be to use the adjustbox package. But that would mean installing (and learning to use) a new package.
IMHO your best bet is to use the \vtop
command.
\vtop{%
\null
\hbox{%
<figure>%
}%
}
So, you will want to enclose your \chemfig
commands inside \vtop{\null\hbox{}}
.
You can even create a macro \topchemfig
to have the desired effect and use it for all your structure figures.
(Somewhat unrelated to the issue at hand, but perhaps you will want to use \raggedright
in rightmost cell to have the text better formatted.)
So, your MWE becomes something like this,
\documentclass{article}
\usepackage[version=3]{mhchem}
\usepackage{chemfig}
\def\topchemfig#1{\vtop{\null\hbox{\chemfig{#1}}}}
\begin{document}
\begin{tabular}{|c|c|p{2.5cm}|}
\hline
Compound & Structure & Hazard Protection \\ \hline
Cyclopentadiene & \topchemfig{*5(-=-=-)} & \raggedright Irritant: Avoid skin contact, ingestion, inhalation, use under hood. Flammable: avoid sources of ignition \\ \hline
\end{tabular}
\end{document}
And your structure becomes perfectly aligned.
This is a job for adjustbox
and its valign=t
feature that makes the box as high as a normal line.
I add also the version using booktabs
commands and no vertical rules. In any case, the first column should be left aligned and the last one is better set as ragged right, because it's very narrow. You might also try \RaggedRight
instead of \raggedright
(requires the ragged2e
package), that allows hyphenation and maybe better fills the lines.
\documentclass{article}
\usepackage{adjustbox,array,booktabs}
\usepackage[version=3]{mhchem}
\usepackage{chemfig}
\begin{document}
\begin{tabular}{|l|c|>{\raggedright\arraybackslash}p{2.5cm}|}
\hline
Compound & Structure & Hazard Protection \\
\hline
Cyclopentadiene &
\adjustbox{valign=t}{\chemfig{*5(-=-=-)}} &
Irritant: Avoid skin contact, ingestion, inhalation, use
under hood. Flammable: avoid sources of ignition \\
\hline
\end{tabular}
\bigskip
\begin{tabular}{lc>{\raggedright\arraybackslash}p{2.5cm}}
\toprule
Compound & Structure & Hazard Protection \\
\midrule
Cyclopentadiene &
\adjustbox{valign=t}{\chemfig{*5(-=-=-)}} &
Irritant: Avoid skin contact, ingestion, inhalation, use
under hood. Flammable: avoid sources of ignition \\
\bottomrule
\end{tabular}
\end{document}