2

When creating HTML using make4ht for a document using the class abnTEX2, the generated document has a new paragraph for each diacritical marks in the abstract (only).

An example file follows:

\documentclass[brazil,article]{abntex2}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\title{Um apólogo}
\author{Machado de Assis}
\begin{document}
\maketitle
\begin{abstract}
Machado de Assis, um homem do século XIX, escreveu o conto
\textit{Um apólogo} abaixo transcrito.
\end{abstract}

Era uma vez uma agulha, que disse a um novelo de linha:

-- Por que está você com esse ar, toda cheia de si, toda
enrolada, para fingir que vale alguma coisa neste mundo?

-- Deixe-me, senhora.

-- Que a deixe? Que a deixe, por quê? Porque lhe digo que
está com um ar insuportável? Repito que sim, e falarei sempre
que me der na cabeça.
\end{document}

When compiled with make4ht -u example I get some errors in \maketitle (without maketitle there is no error)

[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./example.tex    7    Undefined control sequence.

and the result is

document using abnTEX2 generated by make4ht

What's happening in abstract? How to fix it?

1
  • I get an error also with pdflatex it seems that the \tituloestrangeiro{An apologist} must be used. With this change, I can compile document without errors with both pdflatex and make4ht. It doesn't fix the abstract issue, it is another problem :)
    – michal.h21
    Jan 21, 2021 at 21:47

1 Answer 1

2

There is one small issue with your example. I get an error unless I provide the \tituloestrangeiro command. I don't know if it is required by abntex2, but from reading of it's sources it seems that it is required when you use the article document class option. So I've added the following command after \title and it fixed this issue:

\tituloestrangeiro{An apologist}

Now regarding the lines broken on accented characters. This is in fact introduced by make4hth. It makes paragraph for every inline element that is placed directly in the <body> element, so it is outside paragraph or other block element. It does it in order to produce valid HTML. Now TeX4ht produces extra ` element for every accented character in your abstract, but they are not placed inside paragraph, so this mechanism makes one for each one.

To fix this, we must configure abstract environment to produce better output. This can be done using the following .cfg file:

\Preamble{xhtml}
% Configure the abtract environment to produce the <section> element
\ConfigureEnv{abstract}
{\ifvmode\IgnorePar\fi\EndP\HCode{<section role="doc-abstract" class="abstract">\Hnewline}} 
{\ifvmode\IgnorePar\fi\EndP\HCode{</section>}}{}{}
% we want to get rid of the center environment used around the abstract title
% we also introduce a <h3> element for the title
\newenvironment{dummyabstracttitle}{\ifvmode\IgnorePar\fi\EndP\HCode{<h3 class="abstracttitle">}}{\HCode{</h3>}\par\noindent}
% use our dummy environment to insert tags around the abstract title
\renewcommand{\absnamepos}{dummyabstracttitle}
% get rid of all extra <span> elements introduced by smaller font size
\renewcommand{\abstracttextfont}{\normalfont}
\renewcommand{\abstractnamefont}{\normalfont}
% style the abstract
\Css{.abstract{margin:1em;font-size:0.9rem;}}
\Css{.abstracttitle{text-align:center;margin-bottom:1em;}}
\begin{document}
\EndPreamble

I will describe it a bit:

\ConfigureEnv{abstract}
{\ifvmode\IgnorePar\fi\EndP\HCode{<section role="doc-abstract" class="abstract">\Hnewline}} 
{\ifvmode\IgnorePar\fi\EndP\HCode{</section>}}{}{}

This configures the abstract environment to use the <section> element around it's contents.

The abstract title inserted by the class inserts lot of formatting commands to the HTML code, which is really unnecessary. As abntex2 is based on Memoir, we can provide a custom environment to format the title. We do lot of stuff in this environment:

\newenvironment{dummyabstracttitle}{\ifvmode\IgnorePar\fi\EndP\HCode{<h3 class="abstracttitle">}}{\HCode{</h3>}\par\noindent}

The \ifvmode\IgnorePar\fi\EndP commands close potentials opened paragraphs before we insert the <h3> tag. \par\noindent after the end starts a new paragraph, to ensure that the abstract text is inside it.

To get rid most of the <span> elements, which are requested by the fact that a smaller font is used for the abstract contents, we just redefine the commands that choose the abstract font to use the normal font:

\renewcommand{\abstracttextfont}{\normalfont}
\renewcommand{\abstractnamefont}{\normalfont}

The final document looks like this:

enter image description here

You must log in to answer this question.

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