# Conflict between Geometry Ratio-Setting Keys and expl3 Syntax

I have found that when I try to use proportions-setting keys of the geometry package, like hmarginratio = 1:1, in the midst of a expl3 class or package (i.e., such as declared with \ProvidesExpl(Class|Package)), I need to switch off the expl3 syntax temporarily by issuing the \ExplSyntaxOff command before the geometry options, and returning back to expl3 syntax afterwards by issuing \ExplSyntaxOn; otherwise, I get the error message File ended while scanning use of \Gm@sep@ratio.

I guess this might be related to the : mark in the key value, but I'm not sure. Besides, I don't know if this just a bug in my installation or a feature that can be replicated by others.

This is myclass.cls:

\RequirePackage{l3keys2e,xparse}
\ProvidesExplClass
{myclass}
{2013/08/25}
{1.0}
{myclass}

\RequirePackage{calc}

% Fine if the ExplSyntax lines below are uncommented. Error otherwise.
%\ExplSyntaxOff

\RequirePackage[
left = \paperwidth * 3/16,
hmarginratio = 1:1]{geometry}

%\ExplSyntaxOn


And this is test.tex:

\documentclass{myclass}

\begin{document}
Some text.
\end{document}


As you suspect, the problem is that expl3 syntax makes : a 'letter'. Until we have proper interface for all of these things, you have to use a bit of imagination. For example, you could simply

\ExplSyntaxOff
\RequirePackage[
left = \paperwidth * 3/16,
hmarginratio = 1:1]{geometry}
\ExplSyntaxOn


You could use a \lowercase 'trick', but I don't think it's to be recommended.

• Well, that's exactly what I was doing in my OP. So this is a feature... Do you think of this as just a temporary circumstance? – Marcos Aug 28 '13 at 14:33
• @Marcos The way that TeX works is all about category codes. Using : as a 'letter' in expl3 means that anything which uses : directly (as an 'other' character) will have problems. As I say, looking long-term we'd expect to have a LaTeX-based method to set page margins. However, that won't affect how other packages process input: some care will always be needed. – Joseph Wright Aug 28 '13 at 14:35
• Well, I think I can live with that for some time. Hopefully, we'll have a full-fledged LaTeX3 system soon... ;-) It makes for a great experience except when one gets stuck with this kind of stuff. – Marcos Aug 28 '13 at 14:40
• As long as several conventions exists side by side those kind of issues will show up and need resolving by disabling one of the conventions temporarily. Geometry was written without knowing about expl3 but the same would happen if you, say, enable some of the French support packages that make : active. Basic advice is to load/configure 2e packages outside of expl3 conventions as you did. – Frank Mittelbach Aug 28 '13 at 19:42
• @Frank Mittelbach: Good advice indeed! Only it took me a while until I was able to guess what was going on. All in all, I'm liking so much the LaTeX3/expl3-way that I'm migrating to it as much as possible of my LaTeX2e code. As it has been said elsewhere, a "young person's guide" would be very welcome even though we have the help of Joseph Wright's texdev posts in this regard -- which would also make for a very nice starting or reference point for such a guide. – Marcos Aug 28 '13 at 20:12

The colon : is used in expl3 to as a part of function names. It seems you can get around this by smuggling the : in through another macro.

Try the following (since you're in expl syntax to start with)

\ExplSyntaxOff
\def\myhratio{1:1}
\ExplSyntaxOn
\RequirePackage[left=\dimexpr\paperwidth*3/16\relax,
hmarginratio=\myhratio]{geometry}


Incidentally, you might be using the calc package, but if not, then you need to wrap the \paperwidth*3/16 within \dimexpr....\relax

• Using the macro like that doesn't work. I'm afraid I run into the same problem. – Marcos Aug 28 '13 at 14:12
• Well, I think you're going to at least have to switch out of expl syntax so that you can smuggle in the colon. – A.Ellett Aug 28 '13 at 14:14
• But having to do that seems to me quite an unfortunate circumstance: we'd need to be aware every time we set up options including some colon and proceed switching off and on. I think there should be an alternative to it. – Marcos Aug 28 '13 at 14:30