michal-h21 / make4ht

Build system for tex4ht
132 stars 15 forks source link

xtpipes with \AtBeginDocument{\maketitle} in classfile #77

Closed hcf-n closed 2 years ago

hcf-n commented 2 years ago

I have a classfile that causes errors when running make4ht. The line in the classfile causing the error is \AtBeginDocument{\maketitle}

The error is: xtpipes error 37 --- At <xslt name="." xml="." xsl="text-p" > : javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The prefix "text" for element "text:p" is not bound.; The prefix "text" for element "text:p" is not bound.

MWE-class file:

\ProvidesClass{mwe}
\LoadClass[12pt, a4paper]{article}
\RequirePackage[norsk]{babel}
\RequirePackage{fontspec}
% Problematic line
\AtBeginDocument{\maketitle}

MWE:

\documentclass{mwe}
\title{Title}                                                                                                                                                                                                                                                                                                                                                 
\begin{document}
Hello World!
\end{document}
michal-h21 commented 2 years ago

The problem is that when you add code using \AtBeginDocument like this, it is executed before all other tags, which results in error. You can use something like this instead:

\ProvidesClass{mwe}
\LoadClass[12pt, a4paper]{article}
\RequirePackage[norsk]{babel}
\RequirePackage{fontspec}
% Problematic line
% \AtBeginDocument{\maketitle}
\ifdefined\HCode
\AtBeginDocument{\Configure{@BODY}{\maketitle}}
\else
\AtBeginDocument{\maketitle}
\fi

The \AtBeginDocument{\Configure{@BODY}{\maketitle}} line ensures that the \maketitle is inserted at a correct place.

hcf-n commented 2 years ago

Thanks! That works.

michal-h21 commented 2 years ago

That's good to hear. So I hope I can close this.