0

I am the author of the question: Problem with a table with special header: bolded numbers are badly aligned with the rest of the numbers

Following Zarko's advice, I have revised my code according to his suggestion to get my bolded number aligned in the right way. However, a new problem is popping up. I am making another post because I can't share the updated version of my code in my previous post. The previous post does not address the new problem I am facing.

I am trying to make a table with special header.

I tried the following code:

\documentclass[11pt,a4paper]{article}
\usepackage[hyperref]{NAACL2019}
\usepackage[skip=1ex,font=small]{caption}
\usepackage{times}
\usepackage{url}
\usepackage{latexsym}
\usepackage{algorithm} 
\usepackage{algpseudocode} 
\usepackage{sectsty}
\usepackage{amssymb}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{amsmath,epsfig,times}
\usepackage{tabularx} 
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage{subcaption}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{siunitx}  % <---
\usepackage{etoolbox} % <--- 
\newrobustcmd\B{\DeclareFontSeriesDefault[rm]{bf}{b}\bfseries} % <===

\usepackage{hyperref} % load this package last

\begin{table}[ht] \sisetup{detect-weight, mode=text, table-format=1.4} \centering \begin{tabular}{l SS S[table-format=-1.2] S[table-format=1.2] } \toprule & \multicolumn{2}{c}{M1}
& \multicolumn{2}{c}{M2} \ \cmidrule(lr){2-3} \cmidrule(l){4-5} & {1-2} & {7-8} & {1-2} & {7-8} \ \midrule A & \B{0.0021} & \B{0.0033} & -2.37 & 0.00 \ B & \B{0.0052} & \B{0.0042} & -1.23 & 0.67 \ C & 0.0960 & \B{0.0054} & -0.62 & 1.10 \ D & \B{0.0082} & \B{0.0057} & -0.21 & 1.08 \ E & 0.0107 & 0.0097 & 0.74 & 1.41 \ F & \B{0.0080} & 0.0088 & 5.05 & 5.05 \ G & 0.0140 & 0.0148 & -2.37 & 0.00 \ H & 0.0128 & 0.0176 & -1.23 & 0.67 \ I & 0.0157 & 0.0164 & -0.62 & 1.10 \ J & 0.0145 & 0.0155 & -0.21 & 1.08 \ K & 0.0205 & 0.0209 & 0.74 & 1.41 \ L & 0.0236 & 0.0225 & 5.05 & 5.05 \ \bottomrule \end{tabular}%} \smallskip \caption{My Caption} \label{tab:table1} \end{table}

But it gives the following results:

enter image description here

More specifically, I am getting the following errors:

  1. undefined control sequence for the rows A, B, C, and D
  2. and overfull warning for the entire table.

Also, the NAACL template that I am using can be found at: https://www.overleaf.com/latex/templates/instructions-for-naacl-hlt-2019-proceedings/xyyfwfkswhth

How can I resolve this issue?

Marijn
  • 37,699
chico0913
  • 138
  • without an example code it is hard to comment, but do you not get an error message? If you want help with an error always better to show the error message than the pdf output (which is not intended to be usable after an error) also what release of latex are you using (the commands used assume a fairly new release) – David Carlisle Oct 24 '20 at 14:14
  • Hello, thank you for your comment. I have included the details of the error message in my post here...thank you for looking into this for me. – chico0913 Oct 24 '20 at 14:18
  • The posted code works in texlive 2019 and 2020, in texlive 2018 or older you get ! Undefined control sequence. \B ->\DeclareFontSeriesDefault [rm]{bf}{b}\bfseries – David Carlisle Oct 24 '20 at 14:18
  • I am using overleaf to be more specific......does the \DeclarFontSeriesDefault only applicable to LuaLaTeX and such? I am using overleaf PDFLaTeX – chico0913 Oct 24 '20 at 14:20
  • You should show the whole error message or preferable the whole log from a small test document then we would know which release you have. The code assumes a newish latex, although a version could be made for old latex too if updating latex is not an option. But in general for any error don't even look at the pdf, tex's error recovery does not try to make sensible pdf output. Unrelated but don't use epsfig for any documents written this century. – David Carlisle Oct 24 '20 at 14:20
  • you can use texlive 2020 on overleaf check the sidebar menu which texlive you are using (they have 2017,2018,2019,2020 available if I recall correctly) it should look like this – David Carlisle Oct 24 '20 at 14:21
  • Hello thank you so so so much for your help. After switching to texlive 2020, I am able to see the correct result. Thank you again! :) You could make your comment as the answer so that I can give you an upvote and choose your comment as the answer. – chico0913 Oct 24 '20 at 14:23
  • Why you not follows showed suggestion in my answer https://tex.stackexchange.com/questions/568080/problem-with-a-table-with-special-header-bolded-numbers-are-badly-aligned-with/568085#568085. There is nowhere used &\B{<some number>} & ... but only &\B <number> & .... Test of your MWE with repairing this errors and add missed \begin{document} and end{document} works fine! – Zarko Oct 24 '20 at 14:55

1 Answers1

3

Never ignore error messages (it is unfortunate that on overleaf they show the pdf even in case of error, look out for the red circle!)

The commands used in the example require a reasonably new latex (texlive 2020 or an updated 2019) fortunately overleaf has texlive 2020 available, you can check in the sidebar which texlive you are using:

David Carlisle
  • 757,742