1

Using Make4ht how to convert \section to HTML code using elife.cls template?

MWE:

\documentclass{elife}
\usepackage{lipsum}

\title{Grasp movement initiation and representation}

\author[1\authfn{1}]{J. Steven}
\author[2]{S. Manesesh}
\author[1*]{K. Alexanders}
\affil[1]{Department of Clinical and Movement Neurosciences, United Kingdom}
\affil[2]{Gatsby Computational Neuroscience Unit, United Kingdom}

\corr{[email protected]}{AC}

\presentadd[\authfn{1}]{Zanvyl Mind/Brain Institute, United States}

\begin{document}

\maketitle

\begin{abstract}
\lipsum[1-10]
\end{abstract}
\section{Introduction}
We recorded single neurons in F1 and hold actions, and investigated the population-level differences could explain, please refer for each grasp (\FIG{Fig1Main}A) and \FIGSUPP[Fig1Main]{Fig1Supp} how overt movement is withheld during the latter condition.

\begin{figure}
\begin{fullwidth}
\includegraphics[width=0.5\linewidth]{Fig1}
\caption{During task. Top panels show pre-processed, rectified, and normalized average homepad and object displacement signals.}
\label{fig:Fig1Main}
\figsupp[EMG during all traces]{\textbf{(A.)} Execution traces are shown in \FIG{Fig1Main}.}{\includegraphics[width=0.5\linewidth]{Fig1Supp}} \label{figsupp:Fig1Supp}
\end{fullwidth}
\end{figure}

\end{document}

elife LaTeX Template is available here : https://github.com/zhoupc/eLife_submission/blob/master/elife.cls

1 Answer 1

1

It seems that there is a bug in TeX4ht support for the Titlesec package. The elife.cls loads it with the explicit option, which causes patching of sectioning commands by TeX4ht to fail. To work around this, I made a patch file that saves definitions of sections before Titlesec is loaded, and after Titlesec is processed, it overwrites the sections modified by Titlesec by the saved versions.

You need two files, usepackage.4ht which registers the patch file, and titlesec-hooks.4ht which contains the patches.

% usepackage.4ht (2022-02-19-13:30), generated from tex4ht-4ht.tex
% Copyright 2003-2009 Eitan M. Gurari
% Copyright 2009-2022 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2022-02-19-13:30}

   \def\:temp{tex4ht}\ifx \:temp\@currname
   \:warning{\string\usepackage{tex4ht} again?}
   \def\:temp#1htex4ht.def,tex4ht.sty#2!*?: {\def\:temp{#2}}
\expandafter\:temp \@filelist htex4ht.def,tex4ht.sty!*?: %
\ifx \:temp\empty  \else
   \:warning{if
    \string\RequirePackage[tex4ht]{hyperref} or
    \string\usepackage[tex4ht]{hyperref} was
    used try instead, repectively,
    \string\RequirePackage{hyperref} or
    \string\usepackage{hyperref}}
\fi

\fi
\gdef\a:usepackage{\use:package ,!*?: }
\gdef\use:package#1,{%
   \if :#1:\def\:temp##1!*?: {}\else
      \def\:temp{#1}\ifx \@currname\:temp
             \def\:temp##1!*?: {\input usepackage.4ht  }%
      \else \let\:temp=\use:package \fi
   \fi \:temp}
\Configure{PackageHooks}{biblatex-chicago.sty}{biblatex-chicago-hooks.4ht}
\Configure{PackageHooks}{cleveref.sty}{cleveref-hooks.4ht}
\Configure{PackageHooks}{xr.sty}{xr-hooks.4ht}
\Configure{PackageHooks}{xr-hyper.sty}{xrhyper-hooks.4ht}
\Configure{PackageHooks}{eso-pic.sty}{esopic-hooks.4ht}
\Configure{PackageHooks}{showframe.sty}{showframe-hooks.4ht}
\Configure{PackageHooks}{expl3.sty}{expl3-hooks.4ht}
\Configure{PackageHooks}{savetrees.sty}{savetrees-hooks.4ht}
\Configure{PackageHooks}{newcomputermodern.sty}{newcomputermodern-hooks.4ht}
\Configure{PackageHooks}{newcomputermodern.sty}{newcomputermodern-hooks.4ht}
\Configure{PackageHooks}{fontawesome5-utex-helper.sty}%
{fontawesome5-utex-helper-hooks.4ht}
\Configure{PackageHooks}{fontawesome5.sty}{fontawesome5-hooks.4ht}
\Configure{PackageHooks}{biblatex.sty}{biblatex-hooks.4ht}
\Configure{PackageHooks}{xeCJK.sty}{xecjk-hooks.4ht}
\Configure{PackageHooks}{unicode-math.sty}{unicode-math-hooks.4ht}
\Configure{PackageHooks}{ctex.sty}{ctex-hooks.4ht}
\Configure{PackageHooks}{polyglossia.sty}{polyglossia-hooks.4ht}
\Configure{PackageHooks}{fontspec.sty}{fontspec-hooks.4ht}
\Configure{PackageHooks}{tikz.sty}{tikz-hooks.4ht}
\Configure{PackageHooks}{pdfbase.sty}{pdfbase-hooks.4ht}
\Configure{PackageHooks}{pdfx.sty}{pdfx-hooks.4ht}
\Configure{PackageHooks}{breakurl.sty}{breakurl-hooks.4ht}
\Configure{PackageHooks}{hyperref.sty}{hyperref-hooks.4ht}
\Configure{PackageHooks}{caption.sty}{caption-hooks.4ht}
\Configure{PackageHooks}{minted.sty}{minted-sty-hooks.4ht}
\Configure{PackageHooks}{graphics.sty}{graphics-hooks.4ht}
\Configure{PackageHooks}{graphbox.sty}{graphbox-hooks.4ht}
\Configure{PackageHooks}{xcolor.sty}{xcolor-hooks.4ht}
\Configure{PackageHooks}{imakeidx.sty}{imakeidx-hooks.4ht}
\Configure{PackageHooks}{fancyhdr.sty}{fancyhdr-hooks.4ht}
\Configure{PackageHooks}{exerquiz.sty}{exerquiz-hooks.4ht}
\Configure{PackageHooks}{hyperxmp.sty}{hyperxmp-hooks.4ht}
\Configure{PackageHooks}{datetime2.sty}{datetime2-hooks.4ht}
\Configure{PackageHooks}{titlesec.sty}{titlesec-hooks.4ht}


\endinput

titlesec-hooks.4ht:

\let\ttl:chapter\chapter
\let\ttl:section\section
\let\ttl:subsection\subsection
\let\ttl:subsubsection\subsubsection
\let\ttl:paragraph\paragraph
\let\ttl:subparagraph\subparagraph
\:AtEndOfPackage{
\let\chapter\ttl:chapter
\let\section\ttl:section
\let\subsection\ttl:subsection
\let\subsubsection\ttl:subsubsection
\let\paragraph\ttl:paragraph
\let\subparagraph\ttl:subparagraph
}

Then, there are some issues with your TeX file. First of all, you use undefined \FIGSUPP command, and then, you use \figsupp as if it had an optional argument, but it doesn't. It needs two arguments. Here is an updated TeX file:

\documentclass{elife}
\usepackage{lipsum}

\newcommand{\FIGSUPP}[2][]{\ifstrequal{#1}{}{}{\autoref{fig:#1}--}\autoref{figsupp:#2}}

\title{Grasp movement initiation and representation}

\author[1\authfn{1}]{J. Steven}
\author[2]{S. Manesesh}
\author[1*]{K. Alexanders}
\affil[1]{Department of Clinical and Movement Neurosciences, United Kingdom}
\affil[2]{Gatsby Computational Neuroscience Unit, United Kingdom}

\corr{[email protected]}{AC}

\presentadd[\authfn{1}]{Zanvyl Mind/Brain Institute, United States}

\begin{document}

\maketitle

\begin{abstract}
\lipsum[1-10]
\end{abstract}
\section{Introduction}
We recorded single neurons in F1 and hold actions, and investigated the population-level differences could explain, please refer for each grasp (\FIG{Fig1Main}A) and \FIGSUPP[Fig1Main]{Fig1Supp} how overt movement is withheld during the latter condition.

\begin{figure}
\begin{fullwidth}
\includegraphics[width=0.5\linewidth]{Fig1}
\caption{During task. Top panels show pre-processed, rectified, and normalized average homepad and object displacement signals.}
\label{fig:Fig1Main}
\figsupp{EMG during all traces}{\textbf{(A.)} Execution traces are shown in \FIG{Fig1Main}.}{\includegraphics[width=0.5\linewidth]{Fig1Supp}} \label{figsupp:Fig1Supp}
\end{fullwidth}
\end{figure}

\end{document}

This file can be then compiled with this version of elife.4ht:

% \renewcommand{\Authfont}{}
% \renewcommand{\Affilfont}{}

\def\:tempa{%
     \a:themetadata%
     \textbf{*For correspondence:}  \@correspondence\par
     \ifx\empty\@contribution\else
     \c:themetadata\bigskip\@contribution\d:themetadata\fi
     \ifx\empty\@presentaddress\else
     \e:themetadata\textbf{Present address: }\@presentaddress\f:themetadata\fi
     \bigskip
     \ifx\empty\@deceased\else\g:themetadata\@deceased\h:themetadata\fi
     \b:themetadata%
}

\HLet\themetadata\:tempa

% redefine \@author to include affiliations and other information
\def\:tempa{\a:authlist\ifx\AB@affillist\AB@empty\AB@author\else
      \ifnum\value{affil}>\value{Maxaffil}\def\rlap##1{##1}%
    \c:authlist\AB@authlist\d:authlist\themetadata\e:authlist\AB@affillist\f:authlist
    \else  \AB@authors\fi\fi\b:authlist}
\HLet\@author\:tempa

\NewConfigure{themetadata}{8}

\NewConfigure{authlist}{6}

\renewenvironment{abstract}{%
   \textcolor{eLifeLightBlue}{\large\bfseries\abstractname\space}
}{%   
}

\AtBeginDocument{

% Add some formatting around suppinfo
% we must use \protect because we are writting to an auxilary file
\addtostream{suppinfo}{\protect\ifvmode\protect\IgnorePar\protect\fi\protect\EndP\protect\HCode{<div class="suppinfo">}}
\Configure{@/BODY}{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}}

% configure environments in \maketitle
\Configure{authlist}
{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="authlist">}}
{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}}
{\HCode{<div>}}{\HCode{</div><div>}}{\HCode{</div><div>}}{\HCode{</div>}}

\Configure{themetadata}
{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="themetadata">}}
{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}}
{\HCode{<div>}}{\HCode{</div><div>}}{\HCode{</div><div>}}
{\HCode{</div><div>}}{\HCode{</div><div>}}{\HCode{</div>}}
\Css{.themetadata{font-size:0.8rem;}}

\def\IgnoreRule{\special{t4ht@\string_}}
\def\EndIgnoreRule{\special{t4ht@\string_\string_}}

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

\Css{.authlist span{font-size:0.8rem;}}

\Configure{section}{}{}
   {\ifvmode \IgnorePar\fi \EndP\IgnorePar
    \HCode{<h3 class="sectionHead"\a:LRdir>}\TitleMark\space\HtmlParOff}
   {\HCode{</h3>}\HtmlParOn\ShowPar \IgnoreIndent \par}
\Configure{likesection}{}{}
   {\ifvmode \IgnorePar\fi
    \EndP\IgnorePar\HCode{<h3 class="likesectionHead"\a:LRdir>}\HtmlParOff}
   {\HCode{</h3>}\HtmlParOn \IgnoreIndent \ShowPar \par}
}
\Hinput{elife}
\endinput

The difference from the previous file is that I added configurations for the HTML output to the .4ht file.

This is the result:

enter image description here

You must log in to answer this question.

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