2

I'm trying to start my first modular Latex file and I'm using the Wikibook of Latex. I don't know if I'm doing something wrong but I tried to find info about it and I didn't find anything.

I'm using the standalone package and the packages in the child files are not loading. In this case, the package \usepackage[showframe]{geometry} is not loading. The package only loads if I include it in the main file or in the sty file. What I am doing wrong?

These are my files:

main.tex

\documentclass{book}
\usepackage{standalone}
\usepackage{mystyle}

\begin{document}
\input{./tex/dev.tex}
\end{document}

dev.tex

\documentclass{standalone}
\usepackage{../mystyle}

\usepackage[showframe]{geometry}

\begin{document}

\begin{multicols}{2}
\begin{align}
    f(x) &= x^2+uv+u^3xy
\end{align}
\end{multicols}
\end{document}

mystyle.sty

\ProvidesPackage{mystyle}

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{mathrsfs}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{multicol}

\newcommand{\Tau}{\mathcal{T}}
\renewcommand{\r}{\mathbb{R}}
\newcommand{\q}{\mathbb{Q}}
1

2 Answers 2

2

As per the standalone documentation:

The package standalone can be used in the main document to skip all extra preambles in included files. The main file must load all packages and settings required by the sub-files.

Thus, it is a requirement to have the main file load all the packages that are required by the sub-files. My recommendation would be to put the \usepackage[showframe]{geometry} in the mystyle.sty.

0
1

I was bumping into the same problem. Peter's answer still works, but as of today, there is an alternative solution for version v1.3a: the subpreambles=true option for the standalone package. Section 6.2 of the documentation says:

The standalone package removes all sub-file preambles ("sub-preambles") by default when loaded. However, if the package is loaded with the subpreambles options, all sub-preambles are stored in an auxiliary file with the name '〈maintex file name〉.sta' (for standalone). This file is then loaded or processed at the beginning of the next LaTeX run (i.e. at the place in the preamble where the standalone package is loaded).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .