4

I am working in statsoc.cls (you can find it here). Here I show you a working file for the problem I am facing in my paper.

I have a table which has a long-ish caption (2-3 lines). Every time I compile my .tex file, the table moves a little to the right of the page. I think it is because the captions stop wrapping at some point.

\documentclass{statsoc}

%%%% Packages to be used
\usepackage[a4paper]{geometry}
\usepackage{amssymb, amsmath}

\usepackage{graphicx}
\usepackage[caption = false]{subfig} 
\usepackage{enumerate}
\usepackage{comment}
\usepackage{natbib, float}

\title{``Table keeps moving every time I compile''}
\begin{document}

\maketitle

\begin{table}
  \caption{Table moves a little everytime I compile. I think this is because I have a long caption, but I cannot figure out how to resolve this problem. As you can see I am using statsoc.cls. I can reset the table if I delete the .aux file and recompile}
  \fbox{%
    \begin{tabular}{c c c c c c c c c c c c c c c c c c}
    \hline
    1 & 2 & 3 & 4 & 5 & 2 & 3 & 4 & 5 & 1 & 2 & 3 & 4 & 5 & 2 & 3 & 4 & 5\\
    1 & 2 & 3 & 4 & 5 & 2 & 3 & 4 & 5 & 1 & 2 & 3 & 4 & 5 & 2 & 3 & 4 & 5\\
    1 & 2 & 3 & 4 & 5 & 2 & 3 & 4 & 5& 1 & 2 & 3 & 4 & 5 & 2 & 3 & 4 & 5\\
    \hline
    \end{tabular}}
\end{table}
\end{document}

When I delete the .aux file and re-compile, it starts off as this:

enter image description here

Then after one compilation becomes

enter image description here

Then after many more

enter image description here

As I recompile, I make no changes inside the table environment, and work outside it. I believe this question is exactly the same as mine, but the question got closed.

I am not sure if you need more information here. Let me know if you do.

There is an overleaf user who writes here

Note that if your document contains other LaTeX errors, the tables will not be processed correctly. Therefore if you're getting an error message about Missing number and \statsocwidth@b etc, comment out your tables and correct other errors in your code first. Then uncomment your table code, and hit "recompile from scratch" at the bottom of the error/warning message window.

So apparently, every time there is an error, the tables go haywire, and you need to get rid of the aux file.

  • I have no problem with this code. – Bernard Aug 3 '16 at 18:40
  • It works the first couple of times. But after like 10 or so times it starts behaving as such. Could you try a couple of times for me. – Greenparker Aug 3 '16 at 18:41
  • 1
    This class is very strange: it doesn't seem to accept any simple command such as \vspace. – Bernard Aug 3 '16 at 19:19
  • @Bernard I am able to use \vspace in the class. But the problem persists. – Greenparker Aug 3 '16 at 20:24
  • @Greenparker but the class still very strange! please, do you realy need to use it? – touhami Aug 3 '16 at 20:28
5

It's a very obscure bug, due to a spurious space that gets inserted somewhere I couldn't find out. Due to this spurious space, every time the document is compiled, the width assigned to the caption increases by 3.65pt, which is exactly the width of a normal interword space in the selected font.

Here's a workaround.

\documentclass{statsoc}

%%%% Packages to be used
\usepackage[a4paper]{geometry}
\usepackage{amssymb, amsmath}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\@makecaption}
  {\parbox}
  {\advance\@tempdima-\fontdimen2\font\parbox} % decrease the width!
  {}{}
\makeatother  

\usepackage{graphicx}
\usepackage[caption = false]{subfig} 
\usepackage{enumerate}
\usepackage{comment}
\usepackage{natbib, float}

\title{``Table keeps moving every time I compile''}
\author{Don't move!}
\begin{document}

\maketitle

\begin{table}
\caption{Table moves a little everytime I compile. 
  I think this is because I have a long caption, 
  but I cannot figure out how to resolve this problem.
  As you can see I am using statsoc.cls. I can reset
  the table if I delete the .aux file and recompile}
  \fbox{%
    \begin{tabular}{c c c c c c c c c c c c c c c c c c}
    \hline
    1 & 2 & 3 & 4 & 5 & 2 & 3 & 4 & 5 & 1 & 2 & 3 & 4 & 5 & 2 & 3 & 4 & 5\\
    1 & 2 & 3 & 4 & 5 & 2 & 3 & 4 & 5 & 1 & 2 & 3 & 4 & 5 & 2 & 3 & 4 & 5\\
    1 & 2 & 3 & 4 & 5 & 2 & 3 & 4 & 5& 1 & 2 & 3 & 4 & 5 & 2 & 3 & 4 & 5\\
    \hline
    \end{tabular}}
\end{table}
\end{document}

enter image description here

  • 2
    @Greenparker More of a hack than a solution, but as this class is used only for submissions… – egreg Aug 4 '16 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.