3

The following code

\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{pdfpages}
\begin{document}
\includepdf[landscape]{example-image-16x9.pdf}
\end{document}

when compiled with XeLaTeX, produces

! Incomplete \iffalse; all text was ignored after line 5

The conflicting options are landscape on \includepdf and spanish language. Without landscape it compiles, and without babel or with english also compiles good.

The error only appears with XeLaTeX. Neither pdfLaTeX nor luaLaTeX yields that error.

There is something to do?

6
  • I think that the recommended way is to use polyglossia instead of babel in xelatex and lualatex.... But I can't check now. – Rmano Jan 28 '16 at 7:38
  • Hmmm... checked now, I have no error with xelatex on your snippet. Version-dependent? (mine is quite old, it's the stock Ubuntu 14.04, so around TeXLive 2012). – Rmano Jan 28 '16 at 8:29
  • Works for me, too, with the latest release. Please, Emilio, could you say which versions of pdfpages, babel and spanish are used? – Javier Bezos Jan 28 '16 at 14:34
  • @JavierBezos on my system, the problem exists, it is even so severe that the log is cut before \listfiles can produce a result.... compiling with babel loaded second, I get pdfpages.sty 2015/09/18 v0.5d, babel.sty 2016/01/08 3.9n, spanish.ldf 2016/01/15 v5.0o. And XeTeX, Version 3.14159265-2.6-0.99992 (TeX Live 2015) (preloaded format=xelatex 2016.1.20) – user4686 Jan 28 '16 at 17:39
  • @JavierBezos and @Rmano: Debian sid TeXLive 2015.20160117-1. pdfpages version v0.5d and babel 3.9n. Thanks! – Emilio Lazo Jan 29 '16 at 5:34
2

You can disable the pretty useless “quoting” feature of Spanish babel:

\documentclass{article}
\usepackage[spanish,es-noquoting]{babel}
\usepackage{pdfpages}
\begin{document}
\includepdf[landscape]{example-image-16x9.pdf}
\end{document}
4

This is an issue with < and > being active at the wrong time. It appears at a time when the landscape option (and xetex driver for pdfpages) will try to do

\special {pdf: put @thispage <</Rotate #1>>}

I didn't try to disentangle completely the sequence of events (but see update below), but loading babel after pdfpages fixes the issue. I recall from another question I contributed to that spanish has some problems in its handling of active characters, but I need to find that link.

The link is https://tex.stackexchange.com/a/233355/4686 but the underlying mechanism is not the one at works here.

\documentclass{article}
%\usepackage[spanish]{babel}% provokes problems with active <, >
\usepackage{pdfpages}
\usepackage[spanish]{babel}
\begin{document}
%\tracingifs1
%\tracingmacros1
\includepdf[landscape]{example-image-16x9.pdf}
\end{document}
% Local Variables:
% TeX-engine: xetex
% End:

compiles fine (although perhaps the outcome has problems with margins).

Update

One sees in package pdfpages that it does

\AtBeginDocument{%
  \let\AM@orig@landscape\landscape
  \let\AM@orig@endlandscape\endlandscape
  \RequirePackage{pdflscape}%
  \let\landscape\AM@orig@landscape
  \let\endlandscape\AM@orig@endlandscape
}

The important thing is thus that the \RequirePackage{pdflscape} is done at a very late time. If the user loads babel before pdfpages then Babel will have activated the shorthands at that time. And inside package pdflscape one finds

  \def\PLS@AtBeginShipout{%
    \global\setbox\AtBeginShipoutBox\vbox{%
      \special{pdf: put @thispage <</Rotate #1>>}%
      \box\AtBeginShipoutBox
    }%

where the < and > are active characters due to Babel+spanish. If I replace this by

  \def\PLS@AtBeginShipout{%
    \global\setbox\AtBeginShipoutBox\vbox{%
      \special{pdf: put @thispage \string<\string</Rotate #1\string>\string>}%
      \box\AtBeginShipoutBox
    }%

then your MWE compiles with no error, even with babel loaded before pdfpages. Moreover near the bottom of the file pdflscape.sty I see a use of <, > in an \@whilenum loop, here also < and > should better not be active, although here they do not cause problem because they only fetch the next token I believe to check for << or >>.

It can not be said that pdflscape should sanitize the catcodes of < and >, as then zillions of packages should too.

Is it really necessary that pdfpages loads pdflscape during \AtBeginDocument hook ? perhaps an \AtEndOfPackage would be enough ?

6
  • Anyway, babel active characters are a PITA... I normally use tex.stackexchange.com/a/19394/38080, nowadays with utf8 almost universally spread I think they're do more harm than good. Also see tex.stackexchange.com/a/106325/38080 – Rmano Jan 28 '16 at 8:33
  • @Rmano Under xelatex, spanish could perhaps use the \XeTeXintercharclass mechanism rather than active characters. This is what frenchb does, hence no more any worries with active characters. However, there are some remaining fringe issues, it appears not be 100% appropriate enough for insertion of the special spacing for French punctuation, as frenchb author told me. Possibly for things like << and >> in Spanish, the XeTeX `\XeTeXintercharclass would be quite efficient and enough though. – user4686 Jan 28 '16 at 8:39
  • @Rmano actually I don't know how XeTeX mechanism of inter-character classes would interact with a command issuing a \special containing << and >>, as done by \PLS@AtBeginShipout. – user4686 Jan 28 '16 at 8:45
  • 1
    @HeikoOberdiek in pdflscape.sty, I see use of \string<, \string> in the dvips driver part but not in the dvipdfm part. It is clear that generally speaking a standard LaTeX package should not have to worry about <, > being active, but as pdflscape.sty takes precautions for dvips driver, perhaps it could do also for dvipdfm ? – user4686 Jan 28 '16 at 9:02
  • @jfbu In spanish <<>> is unrelated to spacing. – Javier Bezos Jan 28 '16 at 14:36

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.