![make4ht 将脚注容器放在“主要内容”容器内](https://linux22.com/image/474654/make4ht%20%E5%B0%86%E8%84%9A%E6%B3%A8%E5%AE%B9%E5%99%A8%E6%94%BE%E5%9C%A8%E2%80%9C%E4%B8%BB%E8%A6%81%E5%86%85%E5%AE%B9%E2%80%9D%E5%AE%B9%E5%99%A8%E5%86%85.png)
我的 MWE 是:
\documentclass{article}
\begin{document}
Test \footnote{This is a test!}
\end{document}
当我使用此配置文件(.cfg)进行编译时:
\Preamble{xhtml,html5,fn-in}
\Configure{@BODY}{\ifvmode\IgnorePar\fi\EndP\HCode{<main class="main-content">}}
\Configure{@/BODY}{\ifvmode\IgnorePar\fi\EndP\HCode{</main>}}
\begin{document}
\EndPreamble
我得到了类似
<body>
<main class='main-content'> ... </main>
<div class='footnotes'> ... </div>
</body>
我该如何转换它以便脚注位于“主要内容”容器内?像这样:
<body>
<main class='main-content'>
...
<div class='footnotes'> ... </div>
</main>
</body>
答案1
问题在于,该fn-in
选项将脚注写入\Configure{BODY}
,插入在 之后\Configure{@/BODY}
,因此您的结束</main>
标记插入在脚注之前。但是,您可以手动插入脚注,这将阻止默认脚注框:
\Preamble{xhtml,html5,fn-in}
\Configure{@BODY}{\ifvmode\IgnorePar\fi\EndP\HCode{<main class="main-content">}\par\ShowPar}
\catcode`\:=11 % we need to support the ":" character in command names
\Configure{@/BODY}{\ifvmode\IgnorePar\fi\EndP
\ifvoid \fn:box\else
\HCode{<div class="footnotes">}\box\fn:box\HCode{</div>}
\IgnorePar\EndP
\fi
\HCode{\Hnewline</main>}
}%
\catcode`\:=12
\begin{document}
\EndPreamble
结果如下:
<main class='main-content'>
<!-- l. 4 --><p class='indent'> Test <span class='footnote-mark'><a href='#fn1x0' id='fn1x0-bk'><sup class='textsuperscript'>1</sup></a></span><a id='x1-2f1'></a>
<div class='footnotes'><a id='x1-3x'></a>
<!-- l. 4 --><p class='indent'> <span class='footnote-mark'><a href='#fn1x0-bk' id='fn1x0'><sup class='textsuperscript'>1</sup></a></span><span class='cmr-8'>This is a test!</span></p> </div>
</main>