lwarp 不允许不同章节中的部分使用相同的名称。如何修复?

lwarp 不允许不同章节中的部分使用相同的名称。如何修复?

我无法使用 lwarp 在不同的章节中创建具有相同标题的部分。

它不允许我使用相同的章节标题,即使它们位于不同的章节中。它似乎创建了具有章节名称的文件,如果已经有一个具有相同名称的章节,即使它们位于不同的章节中,这也会造成问题。

这是 MWE

\documentclass{book}
\usepackage[mathjax]{lwarp}
\usepackage{amsmath}     
\setcounter{tocdepth}{3} 
\setcounter{secnumdepth}{3} 
\setcounter{FileDepth}{3} 
\setcounter{SideTOCDepth}{3} 


\begin{document}
\title{my page}
\author{me}
\date{\today}
\tableofcontents

\chapter{this is chapter 1} 
\section{my first section} 
\subsection{my first subsection}
   text
\section{my second section}

\chapter{this is chapter 2} 
\section{my first section} 
\subsection{my first subsection}
   text
\section{my second section}% ---> commenting this removes the error
\end{document}

使用编译

lualatex foo.tex
lualatex foo.tex
lwarpmk html

给出

---
Package lwarp:
Processing MathJax customizations for the first HTML page.
Later HTML pages will take the same amount of time.
If this takes too long, see the Lwarp manual regarding customizing MathJax.
Done.
---
[1{/usr/local/texlive/2022/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./foo_html.toc) [2] [3] (./foo_html.sidetoc) [4] [5] [6] [7]
(./foo_html.sidetoc) [8] [9] (./foo_html.sidetoc) [10] [11] [12]

! Package lwarp Error: The section name:
(lwarp)                ``my second section'',
(lwarp)                at the line number listed below,
(lwarp)                generates the filename
(lwarp)                ``my-second-section'',
(lwarp)                which appears to be a duplicate. There is a
(lwarp)                previous section with an identical or similar name.
(lwarp)                While generating file names, Lwarp sanitizes math,
(lwarp)                most symbols, and a few common short words,
(lwarp)                and this may cause a conflict.
(lwarp)                Enter 'H' for possible solutions.

See the lwarp package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.27 \section{my second section}

?

问题是

>ls -lrt *.html
-rwxrwxrwx 1 me me 58694 May 11 06:01 foo_html.html
-rwxrwxrwx 1 me me 14973 May 11 06:01 this-is-chapter-2.html
-rwxrwxrwx 1 me me 14937 May 11 06:01 this-is-chapter-1.html
-rwxrwxrwx 1 me me 14594 May 11 06:01 my-second-section.html
-rwxrwxrwx 1 me me 14031 May 11 06:01 foo.html

它创建了my-second-section.html从第一章调用的文件,并且它不想为第二章中的部分创建另一个同名的文件?

lwarp 中不能有相同的章节标题吗?有解决方法吗?

TL 2022

答案1

按照错误消息的建议去做永远不会有坏处。

你的问题中的信息结束

(lwarp)                Enter 'H' for possible solutions.

但你的日志表明你刚刚滚动过去。h会产生响应

 ...                                              
                                                  
l.26 \section{my second section}
                              % ---> commenting this removes the error
? h
To avoid duplicate filenames, use the optional
short Table of Contents entry:
  \section[Unique name, no math]{Name with math}
or use \texorpdfstring, from the hyperref package:
  \section{
    \texorpdfstring
      {Name with math}{Unique name, no math}
  } 
?

我明白了

./my-second-section1.html
./my-second-section2.html
./this-is-chapter-1.html
./this-is-chapter-2.html

\documentclass{book}
\usepackage[mathjax]{lwarp}
\usepackage{amsmath}     
\setcounter{tocdepth}{3} 
\setcounter{secnumdepth}{3} 
\setcounter{FileDepth}{3} 
\setcounter{SideTOCDepth}{3} 
\usepackage{hyperref}

\begin{document}
\title{my page}
\author{me}
\date{\today}
\tableofcontents

\chapter{this is chapter 1} 
\section{my first section} 
\subsection{my first subsection}
   text
\section[my second section\texorpdfstring{}{1}]{my second section}

\chapter{this is chapter 2} 
\section{my first section} 
\subsection{my first subsection}
   text
\section[my second section\texorpdfstring{}{2}]{my second section}% ---> commenting this removes the error
\end{document}

相关内容