3

I am working on a big project with many subfiles that I wanted to incorporate into one main file. For that, I used the standalone package, to be able to check the individual files for errors, if any appear.

I am able to compile the correctly, but right before the title, I get a bunch of commas. The number is roughly the same as the number of imported files. What is causing this?

\documentclass[10pt]{article}
\usepackage[subpreambles=true]{standalone}
\usepackage{mdframed}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{import}
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\title{test}

\begin{document}
\maketitle
\import{./}{test1.tex}
\import{./}{test2.tex}
\import{./}{test3.tex}
\import{./}{test4.tex}
[26 more imports]
\end{document}

(Edit) The imported files have all the same header, because they are generated automatically with Python:

\documentclass[float=false,crop=false]{standalone}
\usepackage[subpreambles=true]{standalone}
\usepackage{mdframed}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\begin{document}
\section{text}
[...]
\end{document}

Funnily, I commented out all the imports, and the commas continued to appear. The commas also appear when I compile the file on ShareLaTeX.

(Edit2) This is so confusing. I am still a novice with LaTeX, so I don't really understand why I have to compile some stuff twice for the result to appear on Texmaker. I tried it again, and I commented out every import but the first one, compiled twice, and it appeared with one comma. Two imports, two commas, three imports, three commas.

(Edit3) JPi found out the solution! It seems to be some weird interaction between standalone and imports. Removing the geometry line from the imported files removed the weird commas.

(Edit4) The reason for this is a bug in LaTeX, according to Robert. He suggested to use

\PassOptionsToPackage{a4paper,total={6in,8in}}{geometry}

at the main preamble and remove any options in the imported files.

Here is the first page and the title, showing what I mean. image

  • 2
    Welcome! Is the mix of standalone and import supported? We can't reproduce the problem with your code as we don't have the stuff you're importing. Can you provide a minimal file to import which produces the output shown? – cfr Aug 18 '17 at 1:11
  • 1
    What's in test1.tex through test4.tex? – JPi Aug 18 '17 at 2:23
  • ShareLaTeX, on their tutorial on multiple file projects used standalone and import, so that's what I used. The imported files were all generated by Python and have exactly the same header: – K.Cl Aug 18 '17 at 10:58
  • '\documentclass[float=false,crop=false]{standalone}' \usepackage[subpreambles=true]{standalone} \usepackage{mdframed} \usepackage{hyperref} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage[a4paper, total={6in, 8in}]{geometry} \begin{document} \section{The native americans and several other cultures did not experience the same technological advancements as europe. What has caused this diffrence?} [...] – K.Cl Aug 18 '17 at 10:59
  • 1
    If you found my answer helpful please consider accepting it instead of integrating it into your question (in line with the customs on this site). – Robert Oct 1 '17 at 13:26
1

This is actually a glitch in LaTeX: While testing whether a package has been loaded with different options, it stumbles over the brace group in the options to geometry. Neither standalone nor import nor geometry are at fault here; you would get the same spurious commas (accompanied by a Missing \begin{document} error) with a document as simple as this:

\documentclass{article}
\usepackage[total={6in,8in}]{geometry}
\usepackage[total={6in,8in}]{geometry}
\begin{document}
\end{document}

I don't know whether this can be fixed in LaTeX, but you can easily work around it by loading geometry like this in all your files:

\PassOptionsToPackage{a4paper,total={6in,8in}}{geometry}
\usepackage{geometry}

or like this:

\usepackage{geometry}
\geometry{a4paper,total={6in,8in}}

or like this:

\usepackage[a4paper,width=6in,height=8in]{geometry}

which are all equivalent.

|improve this answer|||||
  • Ohhhh, so that's where the commas come from. Interesting. Many thanks for the solution. – K.Cl Aug 18 '17 at 17:27
1

Compiling this with empty test1.tex through test4.tex works fine.

enter image description here

\documentclass[10pt]{article}
\usepackage[subpreambles=true]{standalone}
\usepackage{mdframed}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{import}
\providecommand{\tightlist}{%
    \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\title{test}

\begin{document}
    \author{me}
    \title{none}
    \maketitle
    \import{./}{test1.tex}
    \import{./}{test2.tex}
    \import{./}{test3.tex}
    \import{./}{test4.tex}
    [26 more imports]
\end{document}
|improve this answer|||||
  • I'm sorry, I'm still new at this. It seems I had to compile the files twice. Check my edits to the question, I added information on the preamble of the imports and other things. Thank you. – K.Cl Aug 18 '17 at 11:13
  • Comment out the line loading the geometry package in test1 through test4 and all will be well. – JPi Aug 18 '17 at 13:44
  • Thank you very much! The solutions seems so stupid and simple. I kept focusing on the main file. Do you have any idea what's causing this? I suppose it won't hurt if I omit that part from the preamble of the files, if I'm just going to use them to check small stuff. Would this be something worthy of submitting a bug report? – K.Cl Aug 18 '17 at 14:20
  • Sure, but have a look at the standalone documentation first: it may already be flagged there. – JPi Aug 18 '17 at 15:02

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.