Yan Zhu
Yan Zhu

Reputation: 4346

sphinx doc with different latex versions

Recently, I found some issue with different version of tex. In our company, some are using texlive2018 and some are using texlive2017. In our conf.py, I put

latex_elements = {
    'preamble': '''\usepackage{chngcntr}
                 \counterwithin{figure}{chapter}
                 \counterwithin{table}{chapter}''',
}

It runs OK in texlive2017 but have a redefined error in texlive2018. If I remove \usepackage{chngcntr}, then texlive2018 works, but texlive2017 have a undefined error. Certainly, it is triggered by some changes in newer version of texlive. But I am wondering if there is a way so that it works on both texlive version.

Upvotes: 0

Views: 121

Answers (1)

user4184837
user4184837

Reputation:

Indeed the macros of chngcntr have been moved to the LaTeX format with TeXLive2018.

A new version of chngcntr package starts with this

% version 1.1 this package has been adoped into the format so does not 
% need to do anything in current latex releases.

\@ifundefined{counterwithout}{}{%
\PackageInfo{chngcntr}{\string\counterwithout\space already defined.\MessageBreak
Quitting chngcntr}%
\endinput
}

Thus all should be find if your TeXLive2018 has the v1.1a 2018/04/09 version of the chngctr package. Please check. Is this the Info you see? this is not an Error.

Else you can always do (beware the r else double the backslashes)

latex_elements = {
    'preamble': r'''\ifdefined\counterwithout\else\usepackage{chngcntr}\fi
                 \counterwithin{figure}{chapter}
                 \counterwithin{table}{chapter}''',
}

By the way there was a related issue with the LaTeX format, but it has been fixed since.

Upvotes: 1

Related Questions