这是对tex4ht:自定义列表...(第 2 部分,共 3 部分)
我有一个自定义列表。以下代码提供了页面上<things>
出现的 和 中的位置之间的双向链接。<thing>
List of cmh
问题
我如何调整链接问题的解决方案来解释参数包含\cmhcommand
以下一项或两项的情况:
- 多个段落
- 数学内容
要重现以下代码中的问题,请\cmhcommand{Here is some text}
用\cmhcommand{Here is some text\par a new paragraph}
替换mwe.tex
。
mwe.tex
\documentclass{article}
\usepackage{cmhloc}
\begin{document}
\tableofcontents
\section{normal section}
\cmhcommand{Here is some text}
some text
\section{another secton}
\cmhcommand{Another text}
\cmhcommand{some more}
\listofcmh
\end{document}
cmhloc.sty
\ProvidesPackage{cmhloc}
\newcommand\printcmhentry[1]{#1}
\newcommand{\cmhcommand}[1]{\addcontentsline{cmh}{subsection}{#1}\printcmhentry{#1}}
\newcommand{\listofcmh}{\subsection*{List of cmh}\@starttoc{cmh}}
\endinput
cmhloc.4ht
\RequirePackage{etoolbox}
\def\toccmh#1#2#3{%
\bgroup% make the changes local
\Configure{TocLink}{% This will print the link in TOC.
\Link{##2}{\@nameuse{cmhcn-##4}}##4\EndLink% We need to construct the ID parameter in second parameter for \Link
}
\HCode{<div class="sectionToc">}#2\HCode{</div>\Hnewline}% Print the entry
\egroup%
}%
\newcount\cmhcount % each cmhentry will have it's unique idntifier
\renewcommand\printcmhentry[1]{%
\advance\cmhcount by1\relax%
\edef\cmhlink{cmh-\the\cmhcount}% this will be the id for the corresponding entry in the \listcmh
\csxdef{cmhcn-#1}{\cmhlink}\Link{\cmhlink}{}#1\EndLink} % we use the entry text in csname,
% in order to be able to retrieve the id later
% in the \listcmh entries
\append:def\listofcmh{\TableOfContents[cmh]}
\endinput
compilation sequence
htlatex mwe.tex