我创建了一个命令,以便不让网络链接污染文本。我想改进我的命令,以便执行以下操作。
- 我希望用于 URL 的脚注具有自己的行为、自己的计数器,以及一种用于脚注数量的特殊格式。
- 其他类型的脚注必须保持其通常的行为。
是否可以 ?
这是我的代码。
\documentclass[10pt]{article}
\usepackage{hyperref}
\usepackage{xcolor}
\newcounter{UrlCounter}
\setcounter{UrlCounter}{1}
\newcommand{\myUrl}[1]{%
\textcolor{blue}{\url{http://link/\#\theUrlCounter/}} \footnote{\url{#1}} %
\addtocounter{UrlCounter}{1}%
}
\usepackage{lipsum}
\begin{document}
Let's try to indicate one URL \myUrl{http://www.google.fr/}
and another \myUrl{http://tex.stackexchange.com/}.
I would like to indicate something \footnote{... but here !}.
\lipsum
Let's try to indicate one URL \myUrl{http://www.google.fr/}
and another \myUrl{http://tex.stackexchange.com/}.
I would like to indicate something \footnote{... but here !}.
\end{document}
一个解决方案
感谢以下答案,这里有一个功能代码。我使用了另一个棘手的命令,以便\texttt
与自动返回一起使用,因为我不能将\url
其用于文本中不是真实 URL 的非污染 URL。
% Sources :
% * http://tex.stackexchange.com/questions/35095/special-footnotes-for-url/35097#35097
% * http://forum.mathematex.net/latex-f6/forcer-le-retour-a-la-ligne-dans-texttt-t13246.html#p127511
% * http://tex.stackexchange.com/questions/33465/changing-the-catcode-of-in-one-command
\documentclass[10pt]{article}
\usepackage[svgnames]{xcolor}
\usepackage{manyfoot}
\usepackage{hyperref}
\hypersetup{urlcolor=blue}
% Beakable texttt command.
\makeatletter
\newcommand\breakabletexttt[1]{%
\begingroup\ttfamily
\scantokens{\catcode`\_12\makeatletter\breakable@texttt#1\@nil}%
\endgroup%
}
\def\@gobble@fi#1\fi{\fi#1}
\def\breakable@texttt#1#2\@nil{%
#1\hspace{0pt plus 0.1pt minus 0.1pt}%
\ifx\relax#2\relax
\else
\@gobble@fi\breakable@texttt#2\@nil
\fi
}
\makeatother
% Special footnote
\newfootnote{Url}
\newcounter{footnoteUrl}
\newcommand{\footnoteUrl}{%
% \renewcommand\thefootnoteUrl{\Alph{footnoteUrl}}
\stepcounter{footnoteUrl}%
\Footnotemark{\textcolor{DarkRed}{\textbf{\#\thefootnoteUrl}}}\FootnotetextUrl{}%
}
% Special url
\newcommand{\myUrl}[1]{%
\textcolor{DarkRed}{\textbf{\breakabletexttt{http://link/}}}\footnoteUrl{\, \url{#1}}%
}
\usepackage{lipsum}
\begin{document}
Let's try to indicate one URL \myUrl{http://www.google.fr/}
and another \myUrl{http://tex.stackexchange.com/}.
Let's try to indicate one URL \myUrl{http://www.google.fr/}
and one more \myUrl{http://tex.stackexchange.com/}.
I would like to indicate something \footnote{... but here !}.
\lipsum
Let's try to indicate one URL \myUrl{http://www.google.fr/}
and another \myUrl{http://tex.stackexchange.com/}.
Let's try to indicate one URL \myUrl{http://www.google.fr/}
and one more \myUrl{http://tex.stackexchange.com/}.
I would like to indicate something \footnote{... but here !}.
\end{document}
答案1
使用曼尼福特您可以轻松包创建“新的”脚注;一个小例子:
\documentclass[10pt]{article}
\usepackage{xcolor}
\usepackage{manyfoot}
\usepackage{hyperref}
\hypersetup{urlcolor=blue}
\newfootnote{A}
\newcounter{footnoteA}
\newcommand{\footnoteA}{%
\renewcommand\thefootnoteA{\Alph{footnoteA}}
\stepcounter{footnoteA}%
\Footnotemark\thefootnoteA \FootnotetextA{}}
\newcommand{\myUrl}[1]{%
\footnoteA{\url{#1}}}
\begin{document}
\footnote{standard footnote one}
\myUrl{http://tex.stackexchange.com}
\footnote{standard footnote two}
\myUrl{http://math.stackexchange.com}
\end{document}