3

I was making a template for Journal of Applied Crystallography, example available here (please see Appendix D). Unfortunately, I am getting error mentioned in the title of the question. I followed this answer to resolve the error with out any success. Below you can see a minimum working example. Here you can find .cls file

%------------------------------------------------------------------------------
% Template file for the submission of papers to IUCr journals in LaTeX2e
% using the iucr document class
% Copyright 1999-2003 International Union of Crystallography
% Version 1.2 (11 December 2002)
%------------------------------------------------------------------------------
\documentclass{iucr} % DO NOT DELETE THIS LINE
%-------------------------------------------------------------------------
% Information about the type of paper
%-------------------------------------------------------------------------
\paperprodcode{a000000} % Replace with production code if known
\paperref{xx9999} % Replace xx9999 with reference code if known
\papertype{FA} % Indicate type of article
% FA - research papers (full article)
% SC - short communications
% FC - fast communications
% LA - lead article
% TR - topical review
% XL - crystallization papers
% (Following categories rarely in LaTeX)
% AA - abstracts
% AD - addenda and errata
% AI - inorganic compounds
% AM - metal-organic compounds
% AO - organic compounds
% BC - books received
% BR - book reviews
% BI - biography
% CA - cif applications
% CD - crystal data
% CE - current events
% CI - inorganic compounds
% CL - calendar of events
% CM - metal-organic compounds
% CN - cryocrystallography papers
% CO - organic compounds
% CP - computer programs
% CR - crystallographers
% CS - scientific comment
% ED - editorial
% EI - inorganic compounds
% EM - metal-organic compounds
% EO - organic compounds
% FI - inorganic compounds
% FM - metal-organic compounds
% FO - organic compounds
% IP - issue preface
% IU - iucr
% LE - letters to the editor
% LN - laboratory notes
% ME - forthcoming meetings/short courses
% MR - meeting reports
% NN - notes and news
% NP - new commercial products
% OB - obituaries
% PA - computer program abstracts
% RI - reference information
% SG - structural genomics papers
% SI - short format inorganic compounds
% SM - short format metal-organic compounds
% SO - short format organic compounds
% SP - short structural papers
% SR - software reviews
% TE - teaching and education
\paperlang{english} % Can be english, french, german or russian
%-------------------------------------------------------------------------
% Information about journal to which submitted
%-------------------------------------------------------------------------
\journalcode{J} % Indicate the journal to which submitted
% A - Acta Crystallographica Section A
% B - Acta Crystallographica Section B
% C - Acta Crystallographica Section C
% D - Acta Crystallographica Section D
% E - Acta Crystallographica Section E
% J - Journal of Applied Crystallography
% S - Journal of Synchrotron Radiation
%--------------------------------------------------------------------
% The following entries will be changed as required by editorial staff
%--------------------------------------------------------------------
\journalyr{2003}
\journaliss{1}
\journalvol{59}
\journalfirstpage{000}
\journallastpage{000}
\journalreceived{0 XXXXXXX 0000}
\journalaccepted{0 XXXXXXX 0000}
\journalonline{0 XXXXXXX 0000}


% \let\proof\relax
% \let\endproof\relax
% \usepackage{amsthm}



\begin{document} 

%-------------------------------------------------------------------------
% The introductory (header) part of the paper
%-------------------------------------------------------------------------
% The title of the paper. Use \shorttitle to indicate an abbreviated title
% for use in running heads (you will need to uncomment it).
\title{Title of Paper}
%\shorttitle{Short Title}
% Authors’ names and addresses. Use \cauthor for the main (contact) author.
% Use \author for all other authors. Use \aff for authors’ affiliations.
% Use lower-case letters in square brackets to link authors to their
% affiliations; if there is only one affiliation address, remove the [a].
\cauthor[a]{Forename}{Surname}{email}{address if different from \aff}
\author[b]{Forename}{Surname}
\aff[a]{First affiliation address \country{England}}
\aff[b]{Second affiliation address}
% Use \shortauthor to indicate an abbreviated author list for use in
% running heads (you will need to uncomment it).
%\shortauthor{Soape, Author and Doe}
% Use \vita if required to give biographical details (for authors of
% invited review papers only). Uncomment it.
%\vita{Author’s biography}
% Keywords (required for Journal of Synchrotron Radiation only)
% Use the \keyword macro for each word or phrase, e.g.
% \keyword{X-ray diffraction}\keyword{muscle}
%\keyword{keyword}
% PDB and NDB reference codes for structures referenced in the article and
% deposited with the Protein Data Bank and Nucleic Acids Database (Acta
% Crystallographica Section D). Repeat for each separate structure e.g
% \PDBref[dethiobiotin synthetase]{1byi} \NDBref[d(G$_4$CGC$_4$)]{ad0002}
%\PDBref[optional name]{refcode}
%\NDBref[optional name]{refcode}
\maketitle % DO NOT DELETE THIS LINE
\begin{synopsis}
Supply a synopsis of the paper for inclusion in the Table of Contents.
\end{synopsis}
\begin{abstract}
Abstract goes here.
\end{abstract}
%-------------------------------------------------------------------------
% The main body of the paper
%-------------------------------------------------------------------------
% Now enter the text of the document in multiple \section’s, \subsection’s
% and \subsubsection’s as required.
\section{Section title}

Text text text text text text text text text text text text text text
text text text text text text text.
\subsection{Title}
Text text text text text text text text text text text text text text
text text text text text text text.

\subsubsection{Title}
Text text text text text text text text text text text text text text
text text text text text text text.
% Appendices appear after the main body of the text. They are prefixed by
% a single \appendix declaration, and are then structured just like the
% body text.
\appendix
\section{Appendix title}
Text text text text text text text text text text text text text text
text text text text text text text.
\subsection{Title}
Text text text text text text text text text text text text text text
text text text text text text text.
\subsubsection{Title}
Text text text text text text text text text text text text text text
text text text text text text text.
%-------------------------------------------------------------------------
% The back matter of the paper - acknowledgements and references
%-------------------------------------------------------------------------
% Acknowledgements come after the appendices
\ack{Acknowledgements}
% References are at the end of the document, between \begin{references}
% and \end{references} tags. Each reference is in a \reference entry.

\begin{references}
\reference{Author, A. \& Author, B. (1984). \emph{Journal} \textbf{Vol},
first page--last page.}
\end{references}
%-------------------------------------------------------------------------
% TABLES AND FIGURES SHOULD BE INSERTED AFTER THE MAIN BODY OF THE TEXT
%-------------------------------------------------------------------------
% Simple tables should use the tabular environment according to this
% model
\begin{table}
\caption{Caption to table}
\begin{tabular}{llcr} % Alignment for each cell: l=left, c=center, r=right
HEADING & FOR & EACH & COLUMN \\
\hline
entry & entry & entry & entry \\
entry & entry & entry & entry \\
entry & entry & entry & entry \\
\end{tabular}
\end{table}
% Postscript figures can be included with multiple figure blocks
\begin{figure}
\caption{Caption describing figure.}
\includegraphics{main_gui.eps}
\end{figure}

\end{document} 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1
  • The error Missing \begin{document} is reported here because something is actually typeset before the real start of the document code and text. That, as noted in both answers, is the activation of \RHUBARB. As noted in the answers, it's unclear why that's done, but it's wrong. Sep 28, 2021 at 15:15

2 Answers 2

3

The full message is

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.7364   \RHUBARB
                 % % hack - see above

The offending line is preceded by a comment which translates as "we know this is wrong"...

% The next line is rather mysterious. For some reason the way in which \_ is
% set up requires that it be instantiated in some hidden way like this:
% undoubtedly a subtle bug, but this provides a workaround for current
% dictionaries
\gdef\RHUBARB{\smash{$\phantom{\_}$}}%
  \RHUBARB% % hack - see above

If you delete or comment out the line

\RHUBARB% % hack - see above

Then it runs without error.

5
  • it works, thank you, would you please provide some explanation as well?
    – cswah
    Sep 28, 2021 at 13:30
  • @cswah honestly I could not even guess what the class authors thought this did, it is typesetting a box the width of a _ inside the class file before \begin{document}. I suggested deleting it, If I could guess the intention I would have suggested what to do instead but it just does nothing remotely useful so all I could suggest is deleting it. Sep 28, 2021 at 13:32
  • Well, that cures the error message, but…
    – egreg
    Sep 28, 2021 at 14:11
  • @egreg you know the problem it was trying to solve? Sep 28, 2021 at 14:13
  • @DavidCarlisle They're doing a big mess when typesetting the first section, instead of just asking to \maketitle
    – egreg
    Sep 28, 2021 at 14:15
1

The reason for the error are the strange lines

\gdef\RHUBARB{\smash{$\phantom{\_}$}}%
  \RHUBARB% % hack - see above

but I can say why it used not to raise errors. In 2018 some LaTeX kernel commands were modified to ensure they’re always processed in LR-mode (horizontal mode, in TeXspeak): among them \smash.

Previously, \smash just contributed an \hbox to the main vertical list, so it didn't trigger the Missing \begin{document} error.

On the other hand, removing \RHUBARB does not really fix things: running your document with TeX Live 2017 yields

enter image description here

Commenting out the \RHUBARB line and running with TeX Live 2021 yields

enter image description here

which I’d say cannot be considered good output.

We can notice one other aspect besides the obviously wrong section title: some vertical space is missing after the first rule. The surprising typesetting of “Appendix A” can be cured by adding a blank line before \appendix in the source: it is due to the class using \vspace\baselineskip instead of \vskip\baselineskip or, even better, \par\vspace{\baselineskip}.

You can get the space back by changing

\gdef\RHUBARB{\smash{$\phantom{\_}$}}%
  \RHUBARB% % hack - see above

into

\gdef\RHUBARB{\hbox{\smash{$\phantom{\_}$}}}%
  \RHUBARB% % hack - see above

so the mysterious hack works the same as before.

The wrong typesetting of the section title is cured by commenting out line 1326 in iucr.cls

    \thesection.\ #1\par%
    %\vskip-\baselineskip%
    \vskip4pt minus 4pt}%

Now the output is as expected

enter image description here

3
  • the \RUBARB "hack" isn't actually doing anything is it though, isn't it just the same as using \hbox{} at that point and adding a an empty box, why the phantom \_ ? Sep 28, 2021 at 14:27
  • @DavidCarlisle No idea of how it popped in their minds…
    – egreg
    Sep 28, 2021 at 14:33
  • 1
    If they'd instead used \AtBeginDocument{\RHUBARB} that error wouldn't have happened. Maybe others, but not that one. Sep 28, 2021 at 15:21

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.