1

I want to write a double-sided text with the elegantbook template. It seems that there is a bug in the template. When I choose the the twoside option, elegantbook writes the word beforechap on every empty page.

How can I fix this?

Here is the minimal code example:

\documentclass[12pt,twoside]{elegantbook}

\begin{document} \maketitle \frontmatter \tableofcontents \mainmatter \chapter{xy} \chapter{yz}

\end{document}

Franz X
  • 11
  • 2
    Welcome to TeX.SX! I don't think that the elegantbook class is part of a standard TeX distribution. Therefore, you need to provide more information about where one can find the code for this class. Without access to the code of the class, it is hard to provide a helpful answer. At least, with the class with the same name that can be found on Overleaf, I cannot reproduce this problem. – Jasper Habicht Dec 14 '23 at 12:31
  • It is the class which can be found on overleaf. It is part of the Miktex distribution and can also be found on ctan. – Franz X Dec 14 '23 at 15:03
  • I see, it was indeed included until TeX Live 2022. However, it should be considered obsolete and would not be included in a recent TeX distribution. Anyways, as I said I can't reproduce the problem you encounter: With the above MWE and using TeX Live 2022 on Overleaf, there is nothing wrong with the output. – Jasper Habicht Dec 14 '23 at 15:08
  • It seems that the problem depends on the compiler. I've tried the MWE on the uni halle online compiler and there, the problem doesn't appear. – Franz X Dec 14 '23 at 18:04
  • With the Miktex distribution the problem persists – Franz X Dec 14 '23 at 18:12
  • Same with Texmaker – Franz X Dec 14 '23 at 18:20
  • Texmaker is just an editor. But I can reproduce this indeed with an up-to-date MikTeX installation. Let me check. – Jasper Habicht Dec 14 '23 at 20:31

1 Answers1

1

I think the elegantbook document class that has been distributed with MiKTeX is buggy. On CTAN, the class is marked as obsolete, so it is unclear to me what the current status or the latest version of this document class is.

Anyways, in the latest version that is distributed with MiKTeX (i.e. 2022/04/09 v4.3) we can find the following lines (line 1387 ff. in elegantbook.cls);

\renewcommand*{\cleardoublepage}{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}%
\thispagestyle{empty}%
beforechap\newpage%
\if@twocolumn\hbox{}\newpage\fi\fi\fi}

I can't really say what the author of the document class intended to do here, but this will print the word "beforechap" on every page when the twoside option is active.

A minimally invasive hotfix would be to place this in the pramble of your document and this way delete the annoying word:

\makeatletter
  \renewcommand*{\cleardoublepage}{\clearpage\if@twoside \ifodd\c@page\else
  \hbox{}%
  \thispagestyle{empty}%
  \newpage%
  \if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother

Note that there exists a newer version on GitHub in which this bug has apparently been fixed. Still, I am unsure about the maintenance status of this document class, so I'd rather suggest not to use it.