1

I have just updated to latest TL 2016. I found a problem with subimport not loading a child that uses standalone package when the child has \ifdefined\HCode as its first line.

Here is MWE. I have main.tex and child.tex and main.tex does \subimport{./}{child}. I found that when the child.tex starts with

\ifdefined\HCode
\documentclass[12pt]{article}% 
\else
\documentclass[11pt]{article}
\fi

Then it fails to compile the parent. When I changed the child to only have

\documentclass[12pt]{article}% 

Then it compiles OK.

Here is the main.tex and

\documentclass[12pt]{scrbook}%     
\IfFileExists{luatex85.sty}{\usepackage{luatex85}}{}
\ifdefined\HCode
\usepackage[utf8]{luainputenc}
\usepackage[T1]{fontenc}
\else
\usepackage{fontspec}
\fi

\usepackage{standalone}   
\usepackage{import}
\makeatletter  
\providecommand{\currentimportpath}{\import@path}  
\makeatother   
\usepackage{filecontents}% http://ctan.org/pkg/filecontents        
\begin{document}    
\subimport{./}{child}    
\end{document}

And here is child.tex in same folder.

\ifdefined\HCode
\documentclass[12pt]{article}% 
\else
\documentclass[11pt]{article}
\fi

\IfFileExists{luatex85.sty}{\usepackage{luatex85}}{}

\ifdefined\HCode% detect tex4ht
\usepackage[utf8]{luainputenc}
\usepackage[T1]{fontenc}
\else
\usepackage{fontspec}
\fi

\usepackage{standalone}   
\usepackage{import}
\makeatletter  
\providecommand{\currentimportpath}{\import@path}  
\makeatother   
\usepackage{filecontents}% http://ctan.org/pkg/filecontents
\standalonetrue% This means we are child

\begin{document}
test
\end{document}

Now when compiling main.tex I get this error

lualatex main.tex
This is LuaTeX, Version 0.95.0 (TeX Live 2016) 
 restricted system commands enabled.
(./main.tex
LaTeX2e <2016/03/31> patch level 2
Babel <3.9r> and hyphenation patterns for 1 language(s) loaded.
(/usr/local/texlive/2016/texmf-dist/tex/latex/koma-script/scrbook.cls
Document Class: scrbook 2016/06/14 v3.21 KOMA-Script document class (book)
(/usr/local/texlive/2016/texmf-dist/tex/latex/koma-script/scrkbase.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/koma-script/scrbase.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/koma-script/scrlfile.sty
Package scrlfile, 2016/06/14 v3.21 KOMA-Script package (loading files)
                  Copyright (C) Markus Kohm
 ....
/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/local/texlive/2016/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
ABD: EveryShipout initializing macros (./child.tex

! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.24 \begin{document}

? 

When I change child.tex to have only

 \documentclass[12pt]{article}% 

and no ifdefined\HCode... then it compiles:

problem_june_30_2016>lualatex main.tex
This is LuaTeX, Version 0.95.0 (TeX Live 2016) 
 restricted system commands enabled.
(./main.tex
LaTeX2e <2016/03/31> patch level 2
Babel <3.9r> and hyphenation patterns for 1 language(s) loaded.
.....
(/usr/local/texlive/2016/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
ABD: EveryShipout initializing macros (./child.tex) [1{/usr/local/texlive/2016/
texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./main.aux))
 414 words of node memory still in use:
   3 hlist, 1 vlist, 1 rule, 6 glue, 4 attribute, 49 glue_spec, 4 attribute_lis
t, 1 write nodes
   avail lists: 1:1,2:35,3:3,4:9,5:14,6:29,7:23,8:2,9:15,11:3
</usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmroman12-regular.
otf>
Output written on main.pdf (1 page, 2857 bytes).
Transcript written on main.log.

Here is listfile

 *File List*
 scrbook.cls    2016/06/14 v3.21 KOMA-Script document class (book)
scrkbase.sty    2016/06/14 v3.21 KOMA-Script package (KOMA-Script-dependent bas
ics and keyval usage)
 scrbase.sty    2016/06/14 v3.21 KOMA-Script package (KOMA-Script-independent b
asics and keyval usage)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
scrlfile.sty    2016/06/14 v3.21 KOMA-Script package (loading files)
tocbasic.sty    2016/06/14 v3.21 KOMA-Script package (handling toc-files)
scrsize12pt.clo    2016/06/14 v3.21 KOMA-Script font size class option (12pt)
typearea.sty    2016/06/14 v3.21 KOMA-Script package (type area)
luatex85.sty    2016/06/15 v1.4 pdftex aliases for luatex
fontspec.sty    2016/02/01 v2.5a Font selection for XeLaTeX and LuaLaTeX
   expl3.sty    2016/05/18 v6512 L3 programming layer (loader) 
expl3-code.tex    2016/05/18 v6512 L3 programming layer 
l3pdfmode.def    2016/03/26 v6465 L3 Experimental driver: PDF mode
  xparse.sty    2016/05/18 v6512 L3 Experimental document command parser
luaotfload.sty    2016/06/16 v2.7 OpenType layout system
fontspec-luatex.sty    2016/02/01 v2.5a Font selection for XeLaTeX and LuaLaTeX

 fontenc.sty
  eu2enc.def    2010/05/27 v0.1h Experimental Unicode font encodings
  eu2lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
xunicode.sty    2011/09/09 v0.981 provides access to latin accents and many oth
er characters in Unicode lower plane
 eu2lmss.fd    2009/10/30 v1.6 Font defs for Latin Modern
graphicx.sty    2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2016/06/02 v1.0s Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
  luatex.def    2016/06/17 v0.01e Graphics/Color for luaTeX
infwarerr.sty    2016/05/16 v1.4 Providing info/warning/error messages (HO)
 ltxcmds.sty    2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
fontspec.cfg
standalone.sty    2015/07/15 v1.2 Package to include TeX sub-files with preambl
es
ifluatex.sty    2016/05/16 v1.4 Provides the ifluatex switch (HO)
   ifpdf.sty    2016/05/14 v3.1 Provides the ifpdf switch
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
 xkeyval.sty    2014/12/03 v2.7a package option processing (HA)
 xkeyval.tex    2014/12/03 v2.7a key=value parser (HA)
currfile.sty    2015/04/23 v0.7c Provides the file path elements of the current
 input file
kvoptions.sty    2016/05/16 v3.12 Key value format for package options (HO)
kvsetkeys.sty    2016/05/16 v1.17 Key value parser (HO)
etexcmds.sty    2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
filehook.sty    2011/10/12 v0.5d Hooks for input files
filehook-scrlfile.sty    2011/01/03 v0.1 filehook patch for scrlfile package
gincltex.sty    2011/09/04 v0.3 Include external LaTeX files like graphics
svn-prov.sty    2010/04/24 v3.1862 Package Date/Version from SVN Keywords
adjustbox.sty    2012/05/21 v1.0 Adjusting TeX boxes (trim, clip, ...)
 adjcalc.sty    2012/05/16 v1.1 Provides advanced setlength with multiple back-
ends (calc, etex, pgfmath)
trimclip.sty    2012/05/16 v1.0 Trim and clip general TeX material
collectbox.sty    2012/05/17 v0.4b Collect macro arguments as boxes
  tc-pgf.def    2012/05/13 v1.0 trimclip fall-back clipping driver using PGF
     pgf.sty    2015/08/07 v3.0.1a (rcs-revision 1.15)
  pgfrcs.sty    2015/08/07 v3.0.1a (rcs-revision 1.31)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
  pgfrcs.code.tex
 pgfcore.sty    2010/04/11 v3.0.1a (rcs-revision 1.7)
  pgfsys.sty    2014/07/09 v3.0.1a (rcs-revision 1.48)
  pgfsys.code.tex
pgfsyssoftpath.code.tex    2013/09/09  (rcs-revision 1.9)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2016/05/11 v2.12 LaTeX color extensions (UK)
   color.cfg    2016/01/02 v1.6 sample color configuration
 pgfcore.code.tex
pgfcomp-version-0-65.sty    2007/07/03 v3.0.1a (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v3.0.1a (rcs-revision 1.1)
ifoddpage.sty    2016/04/23 v1.1 Conditionals for odd/even page detection
varwidth.sty    2009/03/30 ver 0.92;  Variable-width minipages
filemod-expmin.sty    2011/09/19 v1.2 Get and compare file modification times (
expandable; minimal)
pdftexcmds.sty    2016/05/21 v0.22 Utility functions of pdfTeX for LuaTeX (HO)
luatex-loader.sty    2016/05/16 v0.6 Lua module loader (HO)
  import.sty    2009/03/23  v 5.1
filecontents.sty    2011/10/08 v1.3 Create an external file from within a LaTeX
 document
   t3cmr.fd    2001/12/31 TIPA font definitions
supp-pdf.mkii
epstopdf-base.sty    2016/05/15 v2.6 Base part for package epstopdf
  grfext.sty    2016/05/16 v1.2 Manage graphics extensions (HO)
kvdefinekeys.sty    2016/05/16 v1.4 Define keys (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
   child.tex
 ***********

Question is: Why it failed to load child, when child starts with \ifdefined\HCode ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.