如何在 tex4ht 中重新配置 maketitle、作者和附属机构

如何在 tex4ht 中重新配置 maketitle、作者和附属机构

我正在尝试重新配置 tex4ht 中的\title{}\author{}\affiliation{}

我无法重新配置,我面临以下问题。

  1. 需要重新配置标题为
  2. 需要配置字幕,但目前打印时没有

    标签

  3. 需要将作者配置为
  4. 每个隶属关系都应该各自

我正在使用 make4ht.exe

如何获得以下预期输出

<div class="maketitle">
    <p class="titleHead">Article Title with bold and Itlaic formating with Inline formula and with footnote</p>
    <p class="subtitle">Chapter Subtitle with bold and formating and a + b = c</p>
    <div class="author" >Xiaotuo Qiao<sup>1,2</sup><orcid>https://orcid.org/000-000-0000</orcid>,&#x00A0;Haifeng Guo<sup class="textsuperscript">1,3</sup><orcid>https://orcid.org/000-000-0001"</orcid>,&#x00A0;and Jun Li<sup class="textsuperscript">3</sup><orcid>https://orcid.org/000-000-0001"</orcid></div>
    <p class="affil"><sup>1</sup>Department of Chemistry, University of Munich (LMU), 81377 Munich, Germany</p>
    <p class="affil"><sup>2</sup>Max Planck Institute for Solid State Research, D-70569 Stuttgart, Germany</p>
    <p class="affil"><sup>3</sup>Max Planck Institute for Solid State Research, D-70569 Stuttgart, Germany</p>
</div>
   

平均能量损失

\documentclass{article}
\usepackage{color,hyperref}

\makeatletter
\newcount\tempcount
\newcount\tempauthorcount
\newcount\authorcount
\newcount\authorcommacount
\newcount\authortempcount
\newcount\tempaffilcount
\newcount\affiliationcount

\def\afid#1{#1}
\def\afn#1{#1}
\def\crsp#1{#1}
\def\abio#1{#1}

\def\subtitle#1{\gdef\@subtitle{#1}}\subtitle{}
\def\supertitle#1{\gdef\@supertitle{#1}}\supertitle{}
\def\author{\@ifnextchar[{\@@AUTHOR}{\@@AUTHOR[]}}

\def\@@AUTHOR[#1]#2#3{%
              \gdef\au@data{yes}%
              \gdef\@thirdarg{#3}%
              \gdef\@secondarg{#2}%
%              \setbox\@tempboxa\hbox{\def\AQ{}#2}%
              \expandafter\protected@xdef\csname author\the\authorcount\endcsname{{#2\textsuperscript{#1}%
                        \ifx\@thirdarg\@empty\else\protect\href{https://orcid.org/#3}{\textcolor{green}{{\fontsize{7}{7}\selectfont\textcircled{{\fontsize{4}{4}\selectfont id}}}}}\fi
                        }}%
              \global\advance\authorcount1%
              }%

\gdef\@author{%
              \global\tempauthorcount\authorcount%
              \global\advance\tempauthorcount-1%
              \global\authorcommacount\tempauthorcount%
              \global\advance\authorcommacount-1%
              \global\authortempcount0%
              \global\authortempcount0%
              \ifnum\authorcount=1%
                \ignorespaces\csname author0\endcsname\unskip\unskip\unskip%
              \else%
                \ifnum\authorcount=2%
                    \ignorespaces\csname author0\endcsname and \csname author1\endcsname\unskip\unskip\unskip%
                \else%
                   \@whilenum\tempcount<\tempauthorcount
                     \do{%
                         \csname author\the\tempcount\endcsname,\ %
                         \global\advance\tempcount1%
                        }%
                         and \csname author\the\tempcount\endcsname\unskip\unskip\unskip\unskip%
                \fi%
              \fi%
             }%
%
\def\affiliation{\@ifnextchar[{\@@affiliation}{\@@affiliation[]}}


\def\@@affiliation[#1]#2{\gdef\@affoptarg{#1}%
                   \gdef\au@data{no}%
                   \global\advance\affiliationcount1%
                    \expandafter\gdef\csname affiliation\the\affiliationcount\endcsname{\textsuperscript{#1}#2}%
                }


\def\printaffiliation{\itshape\parindent=0pt\def\baselinestretch{1}%
           \global\tempcount0%
           \global\tempaffilcount\affiliationcount
           \global\advance\tempaffilcount-1
               \@whilenum\tempcount<\tempaffilcount
                                \do{%
                     %\refstepcounter{afrfilnote}%
                      {\noindent\csname affiliation\the\tempcount\endcsname\unskip\ignorespaces\unskip\unskip\unskip\unskip\unskip\unskip\@@par}%
                     \global\advance\tempcount1}%
                     %\refstepcounter{afrfilnote}%
                      {\noindent\csname affiliation\the\tempcount\endcsname\unskip\unskip\unskip\unskip\unskip\unskip\@@par}%
        \global\authorcount0
        \global\tempauthorcount0
}

\def\corsnotes{}

\def\corresnotes{\@ifnextchar[{\@@CORRS}{\@@CORRS[]}}

\newcount\crspcnt
\newcount\auncnt
\newcount\biocnt


\def\@@CORRS[#1]#2{\advance\crspcnt by 1\g@addto@macro\corsnotes{\ifnum\the\crspcnt>1\vspace*{3pt}\fi\noindent$^{{#1}}$#2\endgraf}}

\def\AUnotes{}

\def\aunotes{\@ifnextchar[{\@@AUNOTES}{\@@AUNOTES[]}}

\def\@@AUNOTES[#1]#2#3{\advance\auncnt by 1\g@addto@macro\AUnotes{\ifnum\the\auncnt>1\else\vspace*{6pt}\fi\noindent$^{{#1}}$#2\endgraf}}

\def\AUBIO{}

\def\bio{\@ifnextchar[{\@@BIO}{\@@BIO[]}}

\def\@@BIO[#1]#2{\advance\biocnt by 1\g@addto@macro\AUBIO{\ifnum\the\biocnt>1\else\vspace*{6pt}\fi\noindent$^{{#1}}$#2\endgraf}}

\def\@maketitle{%
  \newpage
  \null
  \vskip 2em%
  \let \footnote \thanks
  \noindent{\large \@supertitle \par}\vspace*{12pt}
    \noindent{\LARGE \@title \par}
    \ifx\@substitle\@empty
    \else
    \vspace*{12pt}%
    \noindent{\large \@subtitle \par}%
    \fi 
    \vskip 1.5em%
    {%
        \noindent\@author\endgraf%
        \vspace*{6pt}
        {\noindent\printaffiliation\par}%
        \if!\corsnotes!
        \else
        \vspace*{6pt}%
        %\begin{mybox}[colback=white]{Correspondence details}
            {\small\corsnotes\endgraf}%
        %\end{mybox}
        \fi%
        \if!\AUnotes!
        \else
                \vspace*{6pt}%
        %\begin{mybox}[colback=white]{Author Notes}
            {\small\AUnotes\endgraf}
         %\end{mybox}
        \fi
        \if!\AUBIO!%
        \else%
            \vspace*{6pt}%
        \begin{mybox}[colback=white]{Author Bio}
            {\small\AUBIO\endgraf}%
       \end{mybox}
        \fi%
        }%
  \par
  
    \vskip 36pt
  }

\makeatother

\begin{document}


\title{Article Title with \textbf{bold} and \textit{Itlaic formating} with Inline formula and with footnote}

\subtitle{Chapter Subtitle with \textbf{bold} and \textit{formating} and  $a+b=c$}

\author[1,2]{Xiaotuo Qiao}{000-000-0000}
\author[1,3]{Haifeng Guo}{000-000-0001}
\author[3]{Jun Li}{000-000-0002}


\affiliation[1]{Department of Chemistry, University of Munich (LMU), 81377 Munich, Germany}

\affiliation[2]{Max Planck Institute for Solid State Research, D-70569 Stuttgart, Germany}

\affiliation[3]{Max Planck Institute for Solid State Research, D-70569 Stuttgart, Germany}


\maketitle

with various subtle distinctions among them. Even the existence theory for modes is not entirely straightforward: there are already examples in the literature, and this article will supply further examples, of relatively simple probability measures that have no mode. It can even be the case that the average of two disjointly supported unimodal probability measures may have no mode.


\end{document}

答案1

我会将您的自定义命令移至独立包中mytitle.sty

\ProvidesPackage{mytitle}
\newcount\tempcount
\newcount\tempauthorcount
\newcount\authorcount
\newcount\authorcommacount
\newcount\authortempcount
\newcount\tempaffilcount
\newcount\affiliationcount

\def\afid#1{#1}
\def\afn#1{#1}
\def\crsp#1{#1}
\def\abio#1{#1}

\def\subtitle#1{\gdef\@subtitle{#1}}\subtitle{}

\def\printsubtitle{%
  \vspace*{12pt}%
  \noindent{\large \@subtitle \par}%
}

\def\supertitle#1{\gdef\@supertitle{#1}}\supertitle{}
\def\author{\@ifnextchar[{\@@AUTHOR}{\@@AUTHOR[]}}

\def\orcidlogo{\textcolor{green}{{\fontsize{7}{7}\selectfont\textcircled{{\fontsize{4}{4}\selectfont id}}}}}

\def\printorcid#1{\href{https://orcid.org/#1}{\orcidlogo}}

\def\@@AUTHOR[#1]#2#3{%
  \gdef\au@data{yes}%
  \gdef\@thirdarg{#3}%
  \gdef\@secondarg{#2}%
  %              \setbox\@tempboxa\hbox{\def\AQ{}#2}%
  \expandafter\protected@xdef\csname author\the\authorcount\endcsname{{#2\textsuperscript{#1}%
      \ifx\@thirdarg\@empty\else\protect\printorcid{#3}\fi
  }}%
  \global\advance\authorcount1%
}%

\gdef\@author{%
  \global\tempauthorcount\authorcount%
  \global\advance\tempauthorcount-1%
  \global\authorcommacount\tempauthorcount%
  \global\advance\authorcommacount-1%
  \global\authortempcount0%
  \global\authortempcount0%
  \ifnum\authorcount=1%
    \ignorespaces\csname author0\endcsname\unskip\unskip\unskip%
  \else%
    \ifnum\authorcount=2%
      \ignorespaces\csname author0\endcsname and \csname author1\endcsname\unskip\unskip\unskip%
    \else%
      \@whilenum\tempcount<\tempauthorcount
      \do{%
        \csname author\the\tempcount\endcsname,\ %
        \global\advance\tempcount1%
      }%
      and \csname author\the\tempcount\endcsname\unskip\unskip\unskip\unskip%
    \fi%
  \fi%
}%
%

\def\printauthor{\noindent\@author\endgraf}

\def\affiliation{\@ifnextchar[{\@@affiliation}{\@@affiliation[]}}


\def\@@affiliation[#1]#2{\gdef\@affoptarg{#1}%
  \gdef\au@data{no}%
  \global\advance\affiliationcount1%
  \expandafter\gdef\csname affiliation\the\affiliationcount\endcsname{\textsuperscript{#1}#2}%
}

\def\printaffilitem{\noindent\csname affiliation\the\tempcount\endcsname\unskip\ignorespaces\unskip\unskip\unskip\unskip\unskip\unskip\@@par}

\def\printaffiliation{\itshape\parindent=0pt\def\baselinestretch{1}%
  \global\tempcount0%
  \global\tempaffilcount\affiliationcount
  \global\advance\tempaffilcount-1
  \@whilenum\tempcount<\tempaffilcount
  \do{%
    %\refstepcounter{afrfilnote}%
    {\printaffilitem}%
  \global\advance\tempcount1}%
  %\refstepcounter{afrfilnote}%
  % {\noindent\csname affiliation\the\tempcount\endcsname\unskip\unskip\unskip\unskip\unskip\unskip\@@par}%
  {\printaffilitem}%
  \global\authorcount0
  \global\tempauthorcount0
}

\def\corsnotes{}

\def\corresnotes{\@ifnextchar[{\@@CORRS}{\@@CORRS[]}}

\newcount\crspcnt
\newcount\auncnt
\newcount\biocnt


\def\@@CORRS[#1]#2{\advance\crspcnt by 1\g@addto@macro\corsnotes{\ifnum\the\crspcnt>1\vspace*{3pt}\fi\noindent$^{{#1}}$#2\endgraf}}

\def\AUnotes{}

\def\aunotes{\@ifnextchar[{\@@AUNOTES}{\@@AUNOTES[]}}

\def\@@AUNOTES[#1]#2#3{\advance\auncnt by 1\g@addto@macro\AUnotes{\ifnum\the\auncnt>1\else\vspace*{6pt}\fi\noindent$^{{#1}}$#2\endgraf}}

\def\AUBIO{}

\def\bio{\@ifnextchar[{\@@BIO}{\@@BIO[]}}

\def\@@BIO[#1]#2{\advance\biocnt by 1\g@addto@macro\AUBIO{\ifnum\the\biocnt>1\else\vspace*{6pt}\fi\noindent$^{{#1}}$#2\endgraf}}

\def\@maketitle{%
  \newpage
  \null
  \vskip 2em%
  \let \footnote \thanks
  \noindent{\large \@supertitle \par}\vspace*{12pt}
  \noindent{\LARGE \@title \par}
  \ifx\@substitle\@empty
  \else
    \printsubtitle%
  \fi 
  \vskip 1.5em%
  {%
    \printauthor%
    \vspace*{6pt}
    {\noindent\printaffiliation\par}%
    \if!\corsnotes!
    \else
      \vspace*{6pt}%
      %\begin{mybox}[colback=white]{Correspondence details}
      {\small\corsnotes\endgraf}%
      %\end{mybox}
    \fi%
    \if!\AUnotes!
    \else
      \vspace*{6pt}%
      %\begin{mybox}[colback=white]{Author Notes}
      {\small\AUnotes\endgraf}
      %\end{mybox}
    \fi
    \if!\AUBIO!%
    \else%
      \vspace*{6pt}%
      \begin{mybox}[colback=white]{Author Bio}
        {\small\AUBIO\endgraf}%
      \end{mybox}
    \fi%
  }%
  \par

  \vskip 36pt
}

\endinput

您的一些宏非常复杂,混合了计算和内容打印。我已经改变了这一点,使用辅助宏打印内容,这使我们能够插入 XML 标签。然后,您可以为 TeX4ht 创建一个简单的配置文件,mytitle.4ht

\NewConfigure{subtitle}{2}
\pend:def\printsubtitle{\a:subtitle}
\append:def\printsubtitle{\b:subtitle}

\NewConfigure{printauthor}{2}
\pend:def\printauthor{\a:printauthor}
\append:def\printauthor{\b:printauthor}

\NewConfigure{affilitem}{2}
\pend:def\printaffilitem{\a:affilitem}
\append:def\printaffilitem{\b:affilitem}

% 
\NewConfigure{orcid}{1}
\def\:tempa#1{\def\:orcidid{#1}\a:orcid}
\HLet\printorcid\:tempa

\AtBeginDocument{
\Configure{maketitle}
{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="maketitle">}
% reconfigure superscripts inside maketitle
\Configure{textsuperscript}{\HCode{<sup>}\NoFonts}{\EndNoFonts\HCode{</sup>}}
}
{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}}
{\HCode{<p class="titleHead">}}{\HCode{</p>}}

\Configure{thanks author date and}{}{}{}{}{}{}{}{}

\Configure{subtitle}{\ifvmode\IgnorePar\fi\EndP\HCode{<p class="subtitle">}}{\HCode{</p>}}

\Configure{printauthor}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="author">}}{\HCode{</div>}}

\Configure{affilitem}{\ifvmode\IgnorePar\fi\EndP\HCode{<p class="affil">}}{\HCode{</p>}}

\Configure{orcid}{\HCode{<orcid>https://orcid.org/\:orcidid</orcid>}}
}

在第一部分中,它创建了新的钩子,可以使用命令插入标签。使用和命令\Configure将钩子插入到内容打印宏中,这些命令在修补宏的原始内容之前和之后插入代码。\pend:def\append:def

在第二部分,在命令中\AtBeginDocument,我们使用该命令配置这些钩子\Configure。我们在这里执行它,因为我们想覆盖原始的 TeX4ht 配置。

结果如下:

head><body>
   <div class='maketitle'>
                                                                  

                                                                  
                                                                  

                                                                  
<p class='titleHead'><span class='cmr-17'>Article Title with </span><span class='cmbx-12x-x-144'>bold </span><span class='cmr-17'>and </span><span class='cmti-12x-x-144'>Itlaic formating </span><span class='cmr-17'>with
Inline formula and with footnote</span></p>
   <p class='subtitle'><span class='cmr-12'>Chapter Subtitle with </span><span class='cmbx-12'>bold </span><span class='cmr-12'>and </span><span class='cmti-12'>formating </span><span class='cmr-12'>and</span>
<!-- l. 25 --><math display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mrow><mi>a</mi> <mo class='MathClass-bin' stretchy='false'>+</mo> <mi>b</mi> <mo class='MathClass-rel' stretchy='false'>=</mo> <mi>c</mi></mrow></math>
   </p>
   <div class='author'>Xiaotuo Qiao<sup>1,2</sup><orcid>https://orcid.org/000-000-0000</orcid>, Haifeng Guo<sup>1,3</sup><orcid>https://orcid.org/000-000-0001</orcid>, and Jun Li<sup>3</sup><orcid>https://orcid.org/000-000-0002</orcid>
   </div> <p class='affil'><sup>1</sup><span class='cmti-10'>Department of Chemistry, University of Munich (LMU), 81377 Munich,
Germany</span>
</p><p class='affil'><sup>2</sup><span class='cmti-10'>Max Planck Institute for Solid State Research, D-70569 Stuttgart, Germany</span>
</p><p class='affil'><sup>3</sup><span class='cmti-10'>Max Planck Institute for Solid State Research, D-70569 Stuttgart, Germany</span>
</p>
   </div>
<!-- l. 27 --><p class='indent'>   with various subtle distinctions among them. Even the existence theory for
modes is not entirely straightforward: there are already examples in the
literature, and this article will supply further examples, of relatively simple
probability measures that have no mode. It can even be the case that the average
of two disjointly supported unimodal probability measures may have no
mode.
</p>

相关内容