3

I need to define the chaptername to print « Seance 1 ». I use the following example :

\documentclass{report}
\usepackage{lwarp}
\usepackage{lipsum}
\renewcommand{\chaptername}{Seance}
\begin{document}
\chapter{samedi 30 mai 2020}
\lipsum[1]
\end{document}

When I build a pdf file using lualatex, I get what I want.

enter image description here

But when I use lwarp to get a html file, I loose the « Seance » part :

enter image description here

1 Answer 1

4

The lwarp package calls the internal macro \@chapcntformat to print the chapter number. The macro has one argument which is the name of section level, in this case chapter. You can redefine the macro to print \chaptername in front of the number in case of chapters.

MWE:

\documentclass{report}
\usepackage{lwarp}
\usepackage{lipsum}
\renewcommand{\chaptername}{Seance}

\makeatletter
% redefine counter format to include \chaptername
\def\@chapcntformat#1{%
\ifstrequal{#1}{chapter}%
{\chaptername~\csname the#1\endcsname \protect \quad}%
{\csname the#1\endcsname \protect \quad}%
}
\makeatother

\begin{document}
\tableofcontents

\chapter{samedi 30 mai 2020}
\label{mychapter}
\lipsum[1]

\chapter{next meeting}
As discussed in \ref{mychapter}, lorem ipsum dolor sit amet.

\end{document}

Relevant fragment of resulting html:

<h3 id="autosec-3"> <span class="sectionnumber">Seance&nbsp;1&#x2001;</span>samedi 30 mai 2020</h3>

Screenshot:

enter image description here

This workaround seems to work well with the Table of Contents and cross-references, however other things could break that use the modified macro, so it is advised to test properly if the output is still correct with more complex documents.

5
  • Thank you so much. I still have a question : in lwarp.sty, I read, line 13567 : \makeatletter % redefine counter format to include \chaptername \def\@chapcntformat#1{% \ifstrequal{#1}{chapter}% {\chaptername~\csname the#1\endcsname \protect \quad}% {\csname the#1\endcsname \protect \quad}% } \makeatother What is the use of prechaptername and postchaptername ? Is ther e any way to use it here ? Thanks again.
    – Regis C.
    Jun 1, 2020 at 18:20
  • @RegisC. I'm not sure you copied the right piece of code?
    – Marijn
    Jun 1, 2020 at 18:23
  • You are right, sorry about that. Here it is : \@ifundefined{chapter}{}{ \def\@chapcntformat##1{% \prechaptername% \csname the##1\endcsname% \postchaptername% \quad% }
    – Regis C.
    Jun 1, 2020 at 18:31
  • 1
    @RegisC. in the .dtx source it is mentioned that these commands are used in Japanse documentclasses: Usually null, but is used by \pkg{uj*} and \pkg{ut*} Japanese classes. (line 24938 in the .dtx). So unless you write in Japanese you can leave them out. I'm not fully sure what they do, but probably Japanese has some prefix and postfix rules for chapter names that requires these extra macros.
    – Marijn
    Jun 1, 2020 at 18:39
  • OK. Thanks again for your help.
    – Regis C.
    Jun 1, 2020 at 18:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .