loopspace / latex-to-internet

70 stars 1 forks source link

\emph creates spurious errors in text mode. #1

Open rossduncan opened 10 years ago

rossduncan commented 10 years ago

When set as \documentclass[doc]{internet} the following compiles without issue:

\paragraph*{Notation} \emph{I use the subscript $D$ to indicate decimal
notation and subscript $B$ to indicate binary.  For example, $11_D$ is
eleven but $11_B$ is three.}

however with \documentclass[text,xhtml,itex]{internet} the following errors are generated:

! Missing $ inserted.
<inserted text> 
                $
l.137 eleven but $11_B$ is three.}

? 
! Emergency stop.
<inserted text> 
                $
l.137 eleven but $11_B$ is three.}

Removing the \emph makes it work.

loopspace commented 10 years ago

This is a catcode issue. I'm aware of it, but am not sure what the best solution is. There are work-arounds, and if you have any opinion as to what would be the best general solution then I'd love to hear it.

In brief, things in math mode need to act differently to how they normally do. For macros, that's easy: I simply redefine them. But for the special characters then it is a little trickier since their specialness comes from their catcode. The simplest method is to change them to active characters and then define them so that they do the right thing. However, I've found that simply making _ and + active can break other things so I hold off making them active until the very last minute: when math mode starts. Unfortunately, this can sometimes be too late since if the maths is part of the argument to a macro then its catcodes have already been fixed. This is what's happening in this case.

In text mode you can use the commands \itexSetCatcodes and \itexRestoreCatcodes to force the catcode switches (I should define dummy commands in the doc version).

If you are writing your document from scratch (so not trying to convert an old one), then it is probably safe to put

\imode<text>{\itexSetCatcodes}

right after the \begin{document}.

rossduncan commented 10 years ago

Hi Andrew,

Thanks for getting back to me.

I’m not much of TeX hacker so I’m afraid all I can contribute is bug reports. I will try your work around. I did have a look at the code but I couldn’t make head nor tail of it.

Do you have any plans to improve the output of the xhtml mode? If so I could contribute some feature requests.

Regardless, thanks for making internet.cls, I find it quite helpful.

-r

On 23 Jan 2014, at 07:52, Andrew Stacey notifications@github.com wrote:

This is a catcode issue. I'm aware of it, but am not sure what the best solution is. There are work-arounds, and if you have any opinion as to what would be the best general solution then I'd love to hear it.

In brief, things in math mode need to act differently to how they normally do. For macros, that's easy: I simply redefine them. But for the special characters then it is a little trickier since their specialness comes from their catcode. The simplest method is to change them to active characters and then define them so that they do the right thing. However, I've found that simply making _ and + active can break other things so I hold off making them active until the very last minute: when math mode starts. Unfortunately, this can sometimes be too late since if the maths is part of the argument to a macro then its catcodes have already been fixed. This is what's happening in this case.

In text mode you can use the commands \itexSetCatcodes and \itexRestoreCatcodes to force the catcode switches (I should define dummy commands in the doc version).

If you are writing your document from scratch (so not trying to convert an old one), then it is probably safe to put

\imode{\itexSetCatcodes}

right after the \begin{document}.

— Reply to this email directly or view it on GitHub.