# PassOptionsToPackage Order / priority (solving a package class)

I use the teach package (which isn't on ctan but can be downloaded here).

My document was first :

\documentclass[a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}

\usepackage{geometry}
\geometry{hmargin=1cm,vmargin=1cm}
\usepackage[]{teach}

\begin{document}

dsgsgsd

\end{document}


But it ended with the following error :

LaTeX Error: Option clash for package geometry.


Which was triggered by the teach package using geometry package with parameter :

% THIS CODE IS IN TEACH PACKAGE SOURCE
\RequirePackage[%
hmargin=2.5cm,
vmargin=2cm
%,showframe,showcrop
]{geometry}


I found a solution with the \PassOptionsToPackage command :

\PassOptionsToPackage{hmargin=1cm,vmargin=1cm}{geometry}
\documentclass[a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}

\usepackage[]{teach}

\begin{document}

dsgsgsd

\end{document}


I no longer have the error but the margin are wrong (it use the margins defined by teach instead of mine).

I suggest it's because PassOptionsToPackage have lower priority than the ones called by the teach package.

How can I solve my issue ?

• Because I have not that package teach I can not test, but have you simply tried to move line \geometry{hmargin=1cm,vmargin=1cm} **after calling package teach? Do you see that an MWE is important for us to be able to test given code on your own computers to find errors like that you have? – Mensch Jul 31 '19 at 18:27
• Yes I tried moving the \geometry line after calling package teach but I still get the error. I have given MWE, but it's just that the teach package is missing. It can be downloaded here : mathweb.fr/euclide/wp-content/uploads/2018/12/teachV1-4.zip – Matheod Jul 31 '19 at 18:37

Moving

\geometry{hmargin=1cm,vmargin=1cm}


after

\usepackage[]{teach}


and deleting

\usepackage{geometry}


Works so my problem is fixed.

But if someone know a general solution about this (i.e. make \PassOptionsToPackage have priority) please answer this might be usefull in the future to me or someone else.

Complete code:

\documentclass[a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}

\usepackage[]{teach}
\geometry{hmargin=1cm,vmargin=1cm}

\begin{document}

dsgsgsd

\end{document}