This is a question for tex4ht experts.

I'm writing contracts in German language. MWE:

\documentclass[pagesize, ngerman, fontsize=12pt, parskip=half, ref=nosentence]{scrartcl}
\usepackage{babel, scrjura, xspace}

  \DisableLigatures[f]{encoding = *, family = * }

  \Clause{title=First of seven}

This is some text.

Some more text.\label{PAR:second-par}


\Clause{title=Second of seven}

We refer to \ref{CLA:first}.

We refer to \ref{PAR:second-par}.

We refer to \refPar{PAR:second-par}.

We refer to \refParN[arabic]{PAR:second-par}.%%% <= Issue !


The scrjura package comes with a lot of commands to refer to different places of a contract. Some don't work with tex4ht.

If you convert this example file to html using this command:

htlatex example.tex "scrjura" " -cunihtf"

the command \refParN[arabic]{PAR:second-par} will not be converted. The link is simply missing.

scrjura is the name of a config file a very helpful soul once wrote for me. This is the code of scrjura.cfg (for test cases just store in the same folder where example.tex resides):




  {\HCode{<div class=\qtchr contract\qtchr>}}


  {\HCode{<div class=\qtchr paragraph\qtchr>}}


   {\EndP\HCode{<p class=\qtchr para\qtchr>
    <span class=\qtchr sentence\qtchr>}}

 \Css{.sentence{margin-left:2em; padding-top: .5em;}}
 \Css{.paragraph{margin: 1em;}}
 \Css{.para{margin: .5em;}}




If anybody knows how to amend scrjura.cfg to get such links like \refPar converted, I'd be very thankful.

By the way, scrjura.sty years ago used \Paragraph{title=First of seven} instead now \Clause{title=...}.

  • the issue is that Scjura expects cross-references to be in specific format, but tex4ht redefines them to suits them to its needs, so everything gets messy. I am bit busy now, but will look at this issue at the end of the week. – michal.h21 Dec 13 '18 at 9:41
  • I was able to get correct text for \refParN, but links don't work. I will keep trying. – michal.h21 Dec 19 '18 at 7:54
  • @michal.h21 Who cares, if the link works, as long as \refPar and \refParN are converted into e.g. »Absatz 5« or »5«. If this worked, I'd be satisfied, really! – Keks Dose Dec 19 '18 at 9:00
  • you may care :) I will post answer without functional links later today – michal.h21 Dec 19 '18 at 11:35

I've created a proper scrjura.4ht configuration file for tex4ht:

{\ifvmode\IgnorePar\fi\EndP\HCode{<div class=\qtchr contract\qtchr>}}


  {\ifvmode\IgnorePar\fi\end:prevpara\HCode{<div class=\qtchr paragraph\qtchr>}}

% \end:prevpara is needed to correctly handle paragraphs

{\EndP\HCode{<p class=\qtchr para\qtchr>\Hnewline
<span class=\qtchr sentence\qtchr>}}

% this is a modified version of original macro from scrjura.sty
  \expandafter\ifx\csname r@#2\endcsname\relax
      % this definitions are needed to get correct content from the \csname r@#2\endcsname
        \expandafter\expandafter\expandafter\@gobble\csname r@#2\endcsname}%
        \csname r@#2\endcsname\noexpand\@nil}%
          \nfss@text{\reset@font\bfseries ??}%
          \@latex@warning{Reference `#2' on page \thepage \space
            with undefined par number}%
      \expandafter\edef\csname r@#2\endcsname{{\@tempa}\@tempb}%
 \Css{.sentence{margin-left:2em; padding-top: .5em;}}
 \Css{.paragraph{margin: 1em;}}
 \Css{.para{margin: .5em;}}

The issue with \refPar and \refParN macros is that they rely on a specific structure of cross-references, which is different with tex4ht. I've patched the cross-reference handling macro \ref@Par to be somehow compatible. The only issue is that links for these commands don't work, but at least the text seems to be good:

enter image description here

  • Thank you so much! I'm on a business trip and had no time to look into this christmas present. I saved the code as "scrjura.4ht" in the folder were my texfile resides. With the command htlatex filename.tex "scrjura.4ht" " -cunihtf" I'm getting an error: ! Undefined control sequence. l.2 \ConfigureEnv {contract} What am I doing the wrong way? – Keks Dose Dec 20 '18 at 20:25
  • Ah: Is this unreasonable? It works: htlatex filename.tex "scrjura" "scrjura.4ht, -cunihtf" – Keks Dose Dec 20 '18 at 20:35
  • @KeksDose the scrjura.4ht file is loaded automatically, you can just use make4ht filename.tex. (htlatex is deprecated, use make4ht instead) – michal.h21 Dec 20 '18 at 20:53
  • OK, so easy.... So much to learn... – Keks Dose Dec 20 '18 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.