I am trying to use longtables in MDPI article template but their numbering is incorrect (it always starts from 1).
What have I tried so far?
Below is minimal working example. I've stripped the template to bare minimum and added only the things that are necessary.
\documentclass{article}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{paracol}
\title{Tables}
\begin{document}
\begin{paracol}{2}
\switchcolumn
\newcounter{yolo}
\newpage
\begin{table}[h!]
\begin{center}
\caption{Your first table.}
\begin{tabular}{l|c|r} % <-- Alignments: 1st column left, 2nd middle and 3rd right, with vertical lines in between
\textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\
\hline
a & b & c\\
\end{tabular}
\end{center}
\end{table}
\setcounter{yolo}{\thetable}
\theyolo
\end{paracol}
\theyolo
\setcounter{table}{\theyolo}
\begin{longtable}{|l|l|l|}
\caption{A sample long table.} \\
\hline \multicolumn{1}{|c|}{\textbf{First column}} & \multicolumn{1}{c|}{\textbf{Second column}} & \multicolumn{1}{c|}{\textbf{Third column}} \\ \hline
\endfirsthead
\multicolumn{3}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline \multicolumn{1}{|c|}{\textbf{First column}} & \multicolumn{1}{c|}{\textbf{Second column}} & \multicolumn{1}{c|}{\textbf{Third column}} \\ \hline
\endhead
\multicolumn{3}{|r|}{{Continued on next page}} \\ \hline
\endfoot
\endlastfoot
1 & 2 & 3 \\ \hline
\end{longtable}
\begin{paracol}{2}
\switchcolumn
\begin{table}[h!]
\begin{center}
\caption{Your first table.}
\begin{tabular}{l|c|r} % <-- Alignments: 1st column left, 2nd middle and 3rd right, with vertical lines in between
\textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\
\hline
a & b & c\\
\end{tabular}
\end{center}
\end{table}
\setcounter{yolo}{\thetable}
\theyolo
\end{paracol}
\small
\setlength{\arrayrulewidth}{0.2mm}
\renewcommand{\arraystretch}{1.2}
\theyolo
\setcounter{table}{\theyolo}
\begin{longtable}{|l|l|l|}
\caption{A sample long table.}\\
\hline \multicolumn{1}{|c|}{\textbf{First column}} & \multicolumn{1}{c|}{\textbf{Second column}} & \multicolumn{1}{c|}{\textbf{Third column}} \\ \hline
\endfirsthead
\multicolumn{3}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline \multicolumn{1}{|c|}{\textbf{First column}} & \multicolumn{1}{c|}{\textbf{Second column}} & \multicolumn{1}{c|}{\textbf{Third column}} \\ \hline
\endhead
\multicolumn{3}{|r|}{{Continued on next page}} \\ \hline
\endfoot
\endlastfoot
1 & 2 & 3 \\ \hline
\end{longtable}
\end{document}
I've tried to use a counter (named yolo in the example above) that keeps value of tables. Its value is then used to set a counter of longtables. The problem is that for some reason yolo counter seems to have an old value outside of paracol
environment.
To better summarize the problem:
The last number (underlined in red) suppose to be 3, but it is stuck with an old value.
Definitions/mdpi
for example. I would not expect\setcounter{yolo}{\thetable}
to work in general as\thetable
does not need to be an integer. Probablly better with\value{table}
.mdpi.cls
?