1

So I'm making a table with chemfig figures in a particular row. I want these figures to be centered vertically. I tried the answers in this answer, which seemed to work fine. However, I wanted some cell padding as well. That's why I tried the command \renewcommand{\arraystretch}{2} from this answer. However, unfortunately it doesn't seem like this extends to chemfig diagrams.

Then I tried manually adding spaces before and after the table rows and tried centering them that way. This was kind of strange (I had to use negative spaces because sometimes I needed a space before the horizontal line and sometimes afterwards). However, in the fifth row, there appears to be some sort of a space which carries on to other columns as well.

Is there any way I can fix this problem? My MWE is here:

\documentclass[a4paper]{article}

\usepackage{array}
\usepackage[margin=2cm]{geometry}
\usepackage{chemfig}

\begin{document}

\thispagestyle{empty}

\renewcommand{\arraystretch}{2}

\begin{tabular}{|m{4cm}|m{4cm}|}
  \hline
  \textbf{Name of homologous series} & \textbf{Structure} \\
  \hline
  alkene & \chemfig{R-C=C-R'} \\
  \hline
  alkyne & \chemfig{R-C~C-R'} \\
  \hline
  alcohol & \chemfig{R-O-[:-30]H} \\[1.5em]
  \hline
  \\[-2em] ether & \chemfig{R-[:30]O-[:-30]R'} \\
  \hline
\end{tabular}

\end{document}

screenshot

1 Answer 1

3

never use \\ after \hline (the cause of your broken vertical rule) but here I'd use booktabs and its horizontal rules with customisable space.

enter image description here

\documentclass[a4paper]{article}

\usepackage{array,booktabs}
\usepackage[margin=2cm]{geometry}
\usepackage{chemfig}

\begin{document}

\thispagestyle{empty}


\setlength\belowrulesep{10pt}
\setlength\aboverulesep{10pt}

\begin{tabular}{m{4cm}m{4cm}}

  \raggedright\textbf{Name of\\ homologous series} & \textbf{Structure} \\
  \toprule
  alkene & \chemfig{R-C=C-R'} \\
  \midrule
  alkyne & \chemfig{R-C~C-R'} \\
  \midrule
  alcohol & \chemfig{R-O-[:-30]H} \\[1.5em]
  \midrule
  ether & \chemfig{R-[:30]O-[:-30]R'} \\
  \bottomrule
\end{tabular}

\end{document}
1
  • This is truly amazing Apr 3, 2017 at 21:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .