我有以下代码:
\documentclass[a4paper,12pt,twoside,openright]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[italian,english]{babel}
\usepackage[lighttt]{lmodern}
\usepackage[a4paper,top=2.50cm,bottom=2.50cm,left=2.50cm,right=2.50cm]{geometry}
\usepackage{amsmath,amssymb,commath}
\usepackage{siunitx}
\usepackage{physics}
\usepackage[pdftex]{color}
\usepackage{xcolor}
\usepackage[sorting=none]{biblatex}
\usepackage[hyperfootnotes=false]{hyperref}
%hypersetup
\hypersetup{
unicode=false, % non-Latin characters in Acrobat’s bookmarks
pdftoolbar=true, % show Acrobat’s toolbar?
pdfmenubar=true, % show Acrobat’s menu?
pdffitwindow=false, % window fit to page when opened
pdfstartview={FitH}, % fits the width of the page to the window
pdftitle={Renormalization in quantum mechanics: two-dimensional delta-interaction as a case study}, % title
pdfauthor={Me}, % author
pdfsubject={Physics}, % subject of the document
pdfcreator={Me}, % creator of the document
pdfproducer={Me}, % producer of the document
pdfkeywords={theorethical physics, quantum mechanics, renormalization, regularization, effective field theory}, % list of keywords
pdfnewwindow=true, % links in new PDF window
colorlinks=true, % false: boxed links; true: colored links
linktoc=page,
linkcolor=blue, % color of internal link
citecolor=green, % color of links to bibliography
filecolor=magenta, % color of file links
urlcolor=red % color of external links
}
\begin{document}
\tableofcontents
\section{Section 1}
Here there's an equation
\begin{equation}\label{eq1}
\boldsymbol{F} = m\boldsymbol{a}
\end{equation}
\section{Meaning of \eqref{eq1}}
Bla bla...
\end{document}
我想做的是仅删除目录中的公式链接。有人能帮我吗?
答案1
以下是根据我的评论和重新定义部分命令的旧答案给出的答案这里
\documentclass[a4paper,12pt,twoside,openright]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[italian,english]{babel}
\usepackage[lighttt]{lmodern}
\usepackage[a4paper,top=2.50cm,bottom=2.50cm,left=2.50cm,right=2.50cm]{geometry}
\usepackage{amsmath,amssymb,commath}
\usepackage{siunitx}
\usepackage{physics}
\usepackage[pdftex]{color}
\usepackage{xcolor}
\usepackage[sorting=none]{biblatex}
\usepackage[hyperfootnotes=false]{hyperref}
%hypersetup
\hypersetup{
unicode=false, % non-Latin characters in Acrobat’s bookmarks
pdftoolbar=true, % show Acrobat’s toolbar?
pdfmenubar=true, % show Acrobat’s menu?
pdffitwindow=false, % window fit to page when opened
pdfstartview={FitH}, % fits the width of the page to the window
pdftitle={Renormalization in quantum mechanics: two-dimensional delta-interaction as a case study}, % title
pdfauthor={Matteo Tagliazucchi}, % author
pdfsubject={Physics}, % subject of the document
pdfcreator={Matteo Tagliazucchi}, % creator of the document
pdfproducer={Matteo Tagliazucchi}, % producer of the document
pdfkeywords={theorethical physics, quantum mechanics, renormalization, regularization, effective field theory}, % list of keywords
pdfnewwindow=true, % links in new PDF window
colorlinks=true, % false: boxed links; true: colored links
linktoc=page,
linkcolor=blue, % color of internal link
citecolor=green, % color of links to bibliography
filecolor=magenta, % color of file links
urlcolor=red % color of external links
}
\let\oldsection\section
\makeatletter
\def\msection{%
\@ifstar{\@Starred}{\@nonStarred}%
}
\def\@Starred{%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have optional parameters. I am going to ignore them!}\@StarredWith}%
{\@StarredWithout}%
}
\def\@StarredWith[#1]#2{%
\oldsection*{#2}%
}
\def\@StarredWithout#1{
\oldsection*{#1}%
}
\def\@nonStarred{%
\@ifnextchar[%
{\@nonStarredWith}%
{\@nonStarredWithout}%
}
\def\@nonStarredWith[#1]#2{%
\newcommand\myeqref[1]{(\ref*{##1})}
\oldsection[#1]{#2}%
}
\def\@nonStarredWithout#1{%
\oldsection{#1}%
}
\makeatother
\begin{document}
\tableofcontents
\section{Section 1}
Here there's an equation
\begin{equation}\label{eq1}
\boldsymbol{F} = m\boldsymbol{a}
\end{equation}
\msection[Meaning of \myeqref{eq1}]{Meaning of \eqref{eq1}}
Bla bla...
\end{document}
答案2
我建议使用 hyperref 包的钩子\pdfstringdefdisablecommands
来处理 LaTeX 生成 PDF 字符串作为书签或类似内容的情况,这些字符串将在显示 .pdf 文件时由 pdf 查看程序进行评估/处理。这样,您就可以摆脱 hyperref 的“PDF 字符串中不允许使用令牌...”警告。
除此之外,还可以检查标记的定义/状态,\protect
以猜测 LaTeX 是否即将生成普通文本,或者 LaTeX 是否即将处理形成移动参数的标记,该标记将被写入外部文件,例如目录底层的 .toc 文件。
\documentclass[a4paper,12pt,twoside,openright]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[italian,english]{babel}
\usepackage[lighttt]{lmodern}
\usepackage[a4paper,top=2.50cm,bottom=2.50cm,left=2.50cm,right=2.50cm]{geometry}
\usepackage{amsmath,amssymb,commath}
\usepackage{siunitx}
\usepackage{physics}
\usepackage[pdftex]{color}
\usepackage{xcolor}
\usepackage[sorting=none]{biblatex}
\usepackage[hyperfootnotes=false]{hyperref}
%hypersetup
\hypersetup{
unicode=false, % non-Latin characters in Acrobat’s bookmarks
pdftoolbar=true, % show Acrobat’s toolbar?
pdfmenubar=true, % show Acrobat’s menu?
pdffitwindow=false, % window fit to page when opened
pdfstartview={FitH}, % fits the width of the page to the window
pdftitle={Renormalization in quantum mechanics: two-dimensional delta-interaction as a case study}, % title
pdfauthor={Me}, % author
pdfsubject={Physics}, % subject of the document
pdfcreator={Me}, % creator of the document
pdfproducer={Me}, % producer of the document
pdfkeywords={theorethical physics, quantum mechanics, renormalization, regularization, effective field theory}, % list of keywords
pdfnewwindow=true, % links in new PDF window
colorlinks=true, % false: boxed links; true: colored links
linktoc=page,
linkcolor=blue, % color of internal link
citecolor=green, % color of links to bibliography
filecolor=magenta, % color of file links
urlcolor=red % color of external links
}
\makeatletter
\@ifpackageloaded{hyperref}{%
\newcommand\nolinkeqref[1]{%
\textup{\tagform@{\ref*{#1}}}%
}%
\pdfstringdefDisableCommands{%
\def\nolinkeqref#1{(\ref*{#1})}%
\def\eqref#1{(\ref*{#1})}%
}%
}{%
\@ifdefinable\nolinkeqref{%
\let\nolinkeqref=\eqref
}%
}%
\makeatother
\begin{document}
\tableofcontents
\section{Section 1}
Here there's an equation
\begin{equation}\label{eq1}
\boldsymbol{F} = m\boldsymbol{a}
\end{equation}
\section{Meaning of \ifx\protect\relax\eqref{eq1}\else\nolinkeqref{eq1}\fi}
Bla bla...
\end{document}
!!! 注意/在分段命令的参数中使用引用命令时可能存在的陷阱:!!!
在问题中,没有指定使用节标题编写页眉时所需的行为。
如果正在使用的文档类为
\MakeUppercase
包含引用命令的节标题生成大写字母(通过)或类似字母的页眉,则需要特别注意引用标签的名称:当创建页眉时,形成引用标签名称的字母也可能会大写,此时尚未执行所讨论的引用命令,这可能会导致尝试引用,而不是EQ1
(eq1
如果EQ1
未定义)产生未定义的引用,或者(如果EQ1
也已定义)产生对属于具有节标题“含义\eqref{eq1}
”的节的页面的页眉内错误的引用标签的引用。这文本大小写包可能会引起你的兴趣。
\nameref
需要检查 -command的行为,以确定是否引用某个部分\mameref
,而该部分的名称本身包含引用命令。\nameref
如果某个节标题包含对其他节标题的引用,则需要同时考虑 1 和 2 ……