Text FormattingProblem compiling a table environment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
asafw
Posts: 37
Joined: Sun Jun 10, 2012 12:33 pm

Problem compiling a table environment

Post by asafw »

Hi,

I'm using a document class "statsoc" (available from https://rss.onlinelibrary.wiley.com/hub ... guidelines) and having trouble compiling with a simple table example. I couldn't figure out if this is a conflict between packages I'm using or something else.. Any idea?

Thanks so much,
Asaf

Code: Select all

\documentclass{statsoc}

\usepackage{geometry}

\geometry{
  textwidth=33pc,
  textheight=\dimexpr48\baselineskip+\topskip\relax,
  marginparsep=11pt,
  marginparwidth=107pt,
  footnotesep=6.65pt,
  headheight=9pt,
  headsep=9pt,
  footskip=30pt,
}

\usepackage{amsmath,amssymb,amsfonts,graphicx,nicefrac,mathtools,bm}
 \usepackage{natbib}
 \usepackage[english]{babel}
 \usepackage{times}
 \usepackage[T1]{fontenc}
 \usepackage{bbm,mdframed}
 \usepackage[dvipsnames]{xcolor}
 \usepackage{xspace}
 \usepackage{rotating}
 \usepackage{graphics,tikz}
 \usepackage{grffile}
% \usepackage{subcaption}
 \usepackage{epstopdf} % for postscript graphics files 
 \usepackage{listings}
\usepackage[boxruled,linesnumbered]{algorithm2e}
%\usepackage{multirow}
\usepackage{float}


\newtheorem{theorem}{Theorem}
\newtheorem{definition}{Definition}
\newtheorem{lemma}{Lemma}
\newtheorem{corollary}{Corollary}
\newtheorem{remark}{Remark}
 
\renewcommand*{\listalgorithmcfname}{List of Protocols}
\renewcommand*{\algorithmcfname}{Protocol}
\renewcommand*{\algorithmautorefname}{protocol}



\title[Online FCR Control]{Online Control of the False Coverage Rate and\\ False Sign Rate}
\author[author short]{author long}


\begin{document}

\begin{table}[h!]
\centering
\begin{tabular}{||c c c c||} 
 \hline
 Col1 & Col2 & Col2 & Col3 \\ [0.5ex] 
 \hline\hline
 1 & 6 & 87837 & 787 \\ 
 2 & 7 & 78 & 5415 \\
 3 & 545 & 778 & 7507 \\
 4 & 545 & 18744 & 7560 \\
 5 & 88 & 788 & 6344 \\ [1ex] 
 \hline
\end{tabular}
\caption{Table to test captions and labels}
\label{table:1}
\end{table}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Problem compiling a table environment

Post by Ijon Tichy »

statsoc is a publisher class with many restrictions. For example it does not support optional arguments for the table environment and expects \caption at the beginning of the table environment (see the example in the style guide). So respecting the style guide, your table should be something like

Code: Select all

\begin{table}
\caption{\label{table:1}Table to test captions and labels}
\centering
\fbox{%
\begin{tabular}{c c c c} 
 \hline
 Col1 & Col2 & Col2 & Col3 \\ [0.5ex] 
 \hline\hline
 1 & 6 & 87837 & 787 \\ 
 2 & 7 & 78 & 5415 \\
 3 & 545 & 778 & 7507 \\
 4 & 545 & 18744 & 7560 \\
 5 & 88 & 788 & 6344 \\ [1ex] 
 \hline
\end{tabular}}
\end{table}
and indeed this compiles without error.

Usage of packages like float and geometry doe not make much sense if you want to publish your article at wiley. Usually publishers use their own layout, i.e., margins settings. BTW: You should use option mathptm or mathtimes instead of loading package times.

Additional problems could occur if you use packages like subcaption or caption (or even if you actively try to usage float package), because the internals of the class are not made for the usage of such packages and the packages usually do not know such proprietary classes.

Note also, the publisher does provide outdated versions of amssym and natbib with the template. I do not know, whether or not these outdated files interfere with up-to-date versions of AMS packages like amsmath, The publisher should not do so.

If you do not want to use the publisher, I would not use such a special publisher class but a more flexible or general class.

BTW: In case of statsoc the publisher even writes: "it is not compulsory to use it". So maybe it would be a good idea not to use it. ;)
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
vaman
Posts: 17
Joined: Wed Oct 09, 2019 5:51 am

Problem compiling a table environment

Post by vaman »

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{table}[h]
\caption{Table to test captions and labels}\\
\label{table:1}\\
\vspace{.5cm}
\centering
\begin{tabular}{||c c c c||}
\hline
Col1 & Col2 & Col2 & Col3 \\ [0.5ex]
\hline\hline
1 & 6 & 87837 & 787 \\
2 & 7 & 78 & 5415 \\
3 & 545 & 778 & 7507 \\
4 & 545 & 18744 & 7560 \\
5 & 88 & 788 & 6344 \\ [1ex]
\hline
\end{tabular}

\end{table}
\end{document}
You not need any other packages here. in place of cccc, use p{2cm}p(2cm}p{2cm}p{2cm}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Problem compiling a table environment

Post by Stefan Kottwitz »

Hi vaman,

please compare your unformatted code that's not compilable here with Ijons Code, which is formatted, editable and compilable.

Please use the code button - when you post code here, mark it, and click the "Code" button above the edit field. If you have questions, let me know.

Thanks,

Stefan
LaTeX.org admin
vaman
Posts: 17
Joined: Wed Oct 09, 2019 5:51 am

Problem compiling a table environment

Post by vaman »

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{table}[h]
\caption{Table to test captions and labels}\\
\label{table:1}\\
\vspace{.5cm}
\centering
\begin{tabular}{||c c c c||}
\hline
Col1 & Col2 & Col2 & Col3 \\ [0.5ex]
\hline\hline
1 & 6 & 87837 & 787 \\
2 & 7 & 78 & 5415 \\
3 & 545 & 778 & 7507 \\
4 & 545 & 18744 & 7560 \\
5 & 88 & 788 & 6344 \\ [1ex]
\hline
\end{tabular}

\end{table}
\end{document}
%You not need any other packages here. in place of cccc, use %p{2cm}p(2cm}p{2cm}p{2cm}


User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Problem compiling a table environment

Post by Stefan Kottwitz »

Not sure why you introduce line breaks and \vspace between caption and table (as nobody asked for it) but it's wrong. Those \\ cause an error "there's no line here to end".

Stefan
LaTeX.org admin
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Problem compiling a table environment

Post by Ijon Tichy »

@vaman: Why do you show code with class article? The OP asked for a solution with Wiley's class statsoc, which is very different from article. And why do you set option h for the table environment. As I already told, class statsoc does not support options to table. So I do not think, that is make much sense to (try to) show a suggestions with such an option.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply