href 创建脚注而不是可点击的链接

href 创建脚注而不是可点击的链接

我在文档中使用 hyperref 包。我想创建一个指向网页的链接。但是,这总是会创建一个脚注。这可能是由于包冲突造成的,但无法找到问题所在。:(

我使用 overleaf,我的前言是:

\documentclass[mainlanguage=english,colophon-location=nowhere,output=paper,localtocs/depth=subsection,version=final]{yathesis}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{kpfonts}

\usepackage{booktabs}

\usepackage{floatrow}
\usepackage{caption}
\usepackage{microtype}
\usepackage{lipsum}
% \usepackage[nospace]{varioref}


\usepackage{float}
\usepackage[hidelinks, hyperfootnotes=false]{hyperref}

\usepackage[capitalise,noabbrev,nameinlink]{cleveref}

\usepackage{siunitx}
\usepackage{physics}
% \usepackage{braket}

% \usepackage{floatrow}

\usepackage{pdfpages}
\usepackage{feynmp-auto}


\usepackage{csquotes}

\usepackage[perpage, symbol*]{footmisc}

\usepackage{autonum}
\cslet{blx@noerroretextools}\empty



\usepackage[backend=biber,style=numeric-comp,bibstyle=nature,arxiv=pdf,sorting=none,eprint=false,isbn=false,backref=true,url=true]{biblatex}

\DeclareFieldFormat{urldate}{}
  \DeclareFieldFormat{url}{\mkbibacro{URL}\addcolon\space\url{\thefield{urlraw}}}

%user commands
\newcommand{\ahdag}{\hat{a}^{\dagger}}
\newcommand{\ah}{\hat{a}}

\newcommand{\chdag}{\hat{c}^{\dagger}}
\newcommand{\ch}{\hat{c}}

\newcommand{\Sh}{\hat{S}}

\newcommand{\Hh}{\hat{H}}

\newcommand{\Psihdag}{\hat{\Psi}^{\dagger}}
\newcommand{\Psih}{\hat{\Psi}}



\newcommand{\sigmah}{\hat{\sigma}}
\newcommand{\hc}{ + \mathrm{H.c.} \, }



\newcommand{\ds}{\chi''(\Delta_{\mathrm{pa}})}
\newcommand{\dsa}{\chi_\mathrm{a}(\Delta_{\mathrm{pa}})}
\newcommand{\RR}{\mathbb{R}}
\newcommand{\renyi}{R\'{e}nyi }

\DeclareSIUnit\bar{bar}
\DeclareSIUnit\gauss{G}
\DeclareSIUnit\angstrom{\text {Å}}
\AtBeginDocument{\RenewCommandCopy\qty\SI}

导致问题的代码是

\subsection{Optical Layout}
\label{sec:optically_contacted_optics}
\begin{figure}[H]
    \centering
    \includegraphics[width=14.7cm, page= 1]{corps/ch1/figures/Optics_design_with_beams.pdf}
    \caption{\textbf{Design of Optically-Contacted Cavity-Microscope.} \textbf{a}, Schematic of optics including the main laser beams. The cavity mirror (light gray) and the aspheric lens (dark gray) are optically contacted together. The cavity mode is shown in red. The focused beams at \SI{460}{\nm} and \SI{780}{\nm} are drawn in blue and orange. \textbf{b}, Picture of final assembly. An open-access online 3D model of the cavity is shown in Ref.~\cite{sauerwein_quems_2023}. Click \href{https://sketchfab.com/3d-models/quems-cavity-v2018-45564251b3074b21a4fdbd6cc4cc4feb}{here} for quick access.}
    \label{fig:design_optically_contacted}
\end{figure}

结果如下: 在此处输入图片描述

我还必须在参考书目中使用 href 来制作可点击的链接。这也会生成脚注。

提前感谢您的帮助=)!

答案1

文档类的代码中有以下几行:

\ifbool{YAD@output@paper}{%
  \AddToHook{begindocument/before}{%
    \@ifpackageloaded{hyperref}{%
      \YAD@hypersetup{colorlinks=false}%
      \renewcommand{\YAD@href}[3][]{#3}%
      \let\YAD@ori@footnote\footnote%
      \renewcommand{\footnote}[1]{\booltrue{YAD@in@footnote}\YAD@ori@footnote{#1}\boolfalse{YAD@in@footnote}}%
      \renewcommand*\url[1]{\nolinkurl{#1}}%
      \renewcommand*\href[3][]{%
        \ifbool{YAD@in@footnote}{%
          #3 (\url{#2}) }{%
          #3\footnote{\url{#2}} }%
      }%
    }{%
    }%
  }%
}{%
}%

这意味着如果您设置该选项output=paper,URL 将被打印为脚注。

但是,该选项output=paper还会在文档中设置其他内容。因此,如果您想使用此选项但不打印脚注中的 URL,您可以在序言中输入以下内容:

\makeatletter
\ifbool{YAD@output@paper}{%
  \AddToHook{begindocument/before}{%
    \@ifpackageloaded{hyperref}{%
      \renewcommand*\href[3][]{%
          #3 (\url{#2}) }{%
      }%
    }{%
    }%
  }%
}{%
}%
\makeatother

完整 MWE:

\documentclass[output=paper]{yathesis}
\usepackage[T1]{fontenc}
\usepackage{hyperref}

\makeatletter
\ifbool{YAD@output@paper}{%
  \AddToHook{begindocument/before}{%
    \@ifpackageloaded{hyperref}{%
      \renewcommand*\href[3][]{%
          #3 (\url{#2}) }{%
      }%
    }{%
    }%
  }%
}{%
}%
\makeatother

\begin{document}

click \href{https://tex.stackexchange.com/}{here}

\end{document}

在此处输入图片描述

相关内容