2

So, I am trying to write down a table in the "sn-jnl" document class from Springer: when I do it it "article" instead I get exactly what I want:

\documentclass{article}
\usepackage{multirow}

\begin{document}

\begin{tabular}{|c|c|c|} \hline \multirow{2}{*}{A} & B & C \\cline{2-3} & D & E\ \hline \end{tabular}

\end{document}

returns enter image description here

But, once I use the document class I actually want...

\documentclass[sn-mathphys-num]{sn-jnl}
\usepackage{multirow}

\begin{document}

\begin{tabular}{|c|c|c|} \hline \multirow{2}{*}{A} & B & C \\cline{2-3} & D & E\ \hline \end{tabular}

\end{document}

returns an "Undefined control sequence" for \cline: why is that? I can see in the file for the "sn-jnl" class the line

\let\cline\cmidrule

but I am not competent enough with LaTeX to know what that means, or more importantly how to circumvent it.

So, how do I use \cline with the document class "sn-jnl"?

Edit:

@cabonah pointed me to Latex Table Missing Border Lines, which suggests a few possible solutions that have not worked with me.

  • Requiring the package "booktabs" before declaring the document class returned an "Undefined control sequence" for \begin{document};
  • storing the original macro for \cline before declaring the document class resulted in the same problem;
  • all other solutions would imply rewriting my whole table, what I think will be the unfortunate solution in the end...
GVT
  • 173
  • Off-topic: sn-mathphys-num can't be right. Did you mean to specify either sn-math or phys-num? – Mico Mar 06 '24 at 15:29
  • @Mico This was actually specified in the example downloaded from Springer, I kept it as I found it. – GVT Mar 06 '24 at 15:38
  • @GVT - That means there's a mistake in the example code you downloaded from Springer. – Mico Mar 06 '24 at 15:40
  • 1
    @Mico That would not be the first mistake I found in the Springer example, to be honest... – GVT Mar 06 '24 at 15:43
  • @cabonah Sorry, the answers to the linked question are useful but do not solve my problem, I will edit the question to explain that. – GVT Mar 06 '24 at 15:44
  • Actually, I just double-checked the latest version of sn-jnl.cls, and Springer has, in factk, created a new option called, drum roll, sn-mathphys-num. Sorry for the extraneous noise. – Mico Mar 06 '24 at 15:45
  • @GVT I'm sure the answers help, e.g. this one does not only explain, why this issue happens when using multirow, but also how to fix it. BTW: Storing \cline to \clineorig is only half the way, you need to restore it too. And the other answers also work. So it is a duplicate. – cabohah Mar 06 '24 at 15:50
  • @Mico Thanks for the update! – GVT Mar 06 '24 at 15:53
  • "Undefined control sequence" for \begin{document};" suggests you are using texstudio which is somewhat famous for totally mangling error messages so they are meaningless. Ignore the the error "summary" and always look in the log file which will show which command is undefined. – David Carlisle Mar 06 '24 at 16:37

1 Answers1

2

With the sn-jnl document class, you (a) shouldn't use any vertical rules in tables, and (b) replace all instances of \cline with \cmidrule and all instances of \hline with -- depending on the context -- either \toprule, \midrule, or \bottomrule.

Aside: The first argument of \multirow need not be integer-valued.

enter image description here

\documentclass[sn-math]{sn-jnl}
\usepackage{multirow}

\begin{document}

\begin{tabular}{@{} ccc@{}} \toprule \multirow{2.6}{*}{ABC} & D & E \ \cmidrule(l){2-3} & F & G \ \bottomrule \end{tabular}

\end{document}

Mico
  • 506,678
  • Really?! That's because of the "booktabs" package, correct? This is really unfortunate... – GVT Mar 06 '24 at 15:42
  • @GVT - Do please read the first two pages of the user guide of the booktabs package. I'm sure you'll come to agree with the underlying design philosophy. Trust me, once they're gone, you won't miss the vertical lines. – Mico Mar 06 '24 at 15:48
  • I had this design discussion many times, and understand the opinion of the people that dislike vertical rules, yet I keep respectfully disagreeing with them: my table is more of an information dump than anything else. Ugly, super long, but sadly necessary; and the vertical lines help keeping it minimally readable... – GVT Mar 06 '24 at 15:57
  • @GVT - I guess it's time to start looking for a different document class... – Mico Mar 06 '24 at 17:13