tectonic icon indicating copy to clipboard operation
tectonic copied to clipboard

Unable to process `hpdftex.def`

Open AlongWY opened this issue 2 years ago • 5 comments

command: tectonic "acl_latex.tex" -p Input: acl_latex output:

Running TeX ...
(acl_latex.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24> (article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(size11.clo)) (acl.sty
Conference Style for ACL
(xcolor.sty (color.cfg) (xetex.def)) (lineno.sty) (etoolbox.sty) (geometry.sty
(keyval.sty) (ifvtex.sty (iftex.sty))) (caption.sty (caption3.sty)) (natbib.sty
) (hyperref.sty (ltxcmds.sty) (pdftexcmds.sty (infwarerr.sty)) (kvsetkeys.sty)
(kvdefinekeys.sty) (pdfescape.sty) (hycolor.sty) (letltxmacro.sty) (auxhook.sty
) (kvoptions.sty) (pd1enc.def) (intcalc.sty) (etexcmds.sty) (puenc.def)
(url.sty) (bitset.sty (bigintcalc.sty)) (atbegshi-ltx.sty)) (hpdftex.def
(atveryend-ltx.sty)
error: hpdftex.def:207: Undefined control sequence
! Undefined control sequence.
l.207 ...f@majorversion{\number\Hy@pdfmajorversion
                                                  }%
No pages of output.
Transcript written on acl_latex.log.
error: halted on potentially-recoverable error as specified

AlongWY avatar Nov 10 '22 07:11 AlongWY

Hey @AlongWY! Thanks for the issue and the example! 🖤

The document as-is doesn't compile with LuaHBTeX 1.15.0 or XeTeX 3.141592653-2.6-0.999994 either, only with pdfTeX 3.141592653-2.6-1.40.24. Note that tectonic is not a pdfLaTeX engine, but a XeTeX-based one, and as such there will be incompatibilities. Still, we want to smooth some of those whenever we can, so this is an interesting one.

You can make it compile correctly by first commenting out the offending line:

% \pdfoutput=1

And then running tectonic:

tectonic acl_latex.tex

Give it a go and let me know how it goes 🚀

Neved4 avatar Nov 10 '22 10:11 Neved4

@pkgw I find this one interesting, in theory we have a test for \pdfoutput so things don't blow up, yet here is a document that won't compile correctly at all when that line is present.

Neved4 avatar Nov 10 '22 10:11 Neved4

This is the "\pdfoutput=1 Arxiv-Tectonic problem". See https://github.com/tectonic-typesetting/tectonic/issues/916 and https://github.com/tectonic-typesetting/tectonic/issues/863. This topic seems to be a great candidate for a good solution in the first place and an FAQ entry.

I don't have experience with submitting to Arxiv myself, but I understand the need. From what I gather acl_latex.tex is a template for your documents, so you can modify it as you like. This is a great start.

To summarize, I assume you have the following goals:

  1. Submit succesfully your document to Arxiv, where you want to produce .pdf file using PDFLaTeX,
  2. Be able to compile the document locally with Tectonic.

Note that 1) will also allow you to compile with pdflatex locally, so you can test the output locally before submitting (I don't know how easy Arxiv makes it to "debug" your TeX problems by repeatedly uploading the sources). Though this would require e.g. TeX Live installed.

In one of the issues I linked I explained what \pdfoutput=1 does and why I think it is not a good idea to have it in Tectonic (especially when it is a dummy that does nothing). But you need to execute that line somehow if you are submitting to Arxiv. So you can do it conditionally:

\usepackage{iftex}
\iftutex
  % running under Unicode TeX engine (XeTeX, LuaTeX), use modern things
  \usepackage{fontspec}
  \setmainfont{TeX Gyre Termes}
  \usepackage{unicode-math}
  \setmathfont{Stix Two Math}
\else
  % running something older, ensure pdfTeX is used (i.e `pdflatex` or `latex`)
  \RequirePDFTeX
  % additionally, force `latex` to produce PDF output (needed for Arxiv)
  \pdfoutput=1
  % use old things
  \usepackage{newtxtext,newtxmath}
\fi

For example for acl_latex.tex I would replace the preamble (upto \usepackage{microtype}) with the following:

\documentclass[11pt]{article}

% Remove the "review" option to generate the final version.
\usepackage[review]{acl}

\usepackage{iftex}
\iftutex
  % running under Unicode TeX engine (XeTeX, LuaTeX), use modern things
  \usepackage{fontspec}
  \setmainfont{TeX Gyre Termes}
\else
  % running something older, ensure pdfTeX is used (i.e `pdflatex` or `latex`)
  \RequirePDFTeX
  % additionally, force `latex` to produce PDF output (needed for Arxiv)
  \pdfoutput=1

  % use old things

  \usepackage{times}

  % For proper rendering and hyphenation of words containing Latin characters (including in bib files)
  \usepackage[T1]{fontenc}
  % For Vietnamese characters
  % \usepackage[T5]{fontenc}
  % See https://www.latex-project.org/help/documentation/encguide.pdf for other character sets

  % This assumes your files are encoded as UTF8
  \usepackage[utf8]{inputenc}
\fi

\usepackage{latexsym}

% This is not strictly necessary, and may be commented out,
% but it will improve the layout of the manuscript,
% and will typically save some space.
\usepackage{microtype}

Note that I moved "old style packages" like inputenc and fontenc to the pdfTeX "old" branch and tried to find alternatives for Unicode engines (like XeTeX, which is what Tectonic corresponds to). Other things that are TeX engine independent can stay out of the \if \else \fi (either before or after -- as usual consult package documentation whether they require ceratain ordering, e.g. hyperref is recommended to be loaded last).

This setup means that what you compile locally will not be the same as what gets compiled on Arxiv. You have to decide whether this is something that is OK with you. Perhaps even the "old style" packages work with XeLaTeX / Tectonic unchanged -- I very briefly tried and failed (frankly this is something I am not keen on debugging further).

So far except for the weird handling of \pdfoutput in Tectonic (that I disagree with) nothing here is really Tectonic specific -- if you want your documents to compile with Tectonic you should try to make them compatible with XeLaTeX. Better (full?) compatibility of Tectonic with PDFLaTeX is currently being discussed - https://github.com/tectonic-typesetting/tectonic/discussions/956.

vlasakm avatar Nov 10 '22 13:11 vlasakm

Thanks a lot. The answer helped me. But the \setmainfont{TeX Gyre Termes} not work. I removed the line and it works for me. Thanks again.

AlongWY avatar Nov 17 '22 08:11 AlongWY

@AlongWY Sorry, I didn't realize that by doing \setmainfont{TeX Gyre Termes} I am triggering https://github.com/tectonic-typesetting/tectonic/issues/9 (see https://github.com/tectonic-typesetting/tectonic/issues/965#issuecomment-1317865762 for details).

Instead of:

\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}

try:

\usepackage{fontspec}
\setmainfont{texgyretermes}[
	Extension      = .otf,
	UprightFont    = *-regular,
	BoldFont       = *-bold,
	ItalicFont     = *-italic,
	BoldItalicFont = *-bolditalic]

vlasakm avatar Nov 17 '22 09:11 vlasakm