如何让第二段超链接文本中的文本遵循与第一段相同的悬挂段落缩进?我尝试在块hangparas
内放置一个新环境href
,但这只会产生\pdfendlink cannot be used in vertical mode
错误。
我已将我希望的完整示例发布于下方。
\documentclass[12pt]{report}
\usepackage{breakurl}
\usepackage{hanging}
\usepackage[breaklinks]{hyperref}
\begin{document}
\begin{hangparas}{0.25in}{1}
This is a demonstration that, normally, the hanging text mode will work perfectly, no matter what kind of silly text I put in it.
\href{http://google.com}{This is a demonstration that, normally, the hanging text mode will not work perfectly when I put some kind of URL inside it, and I don't know why.}
\end{hangparas}
\end{document}
答案1
发生这种情况是因为链接文本是在组内排版的。这导致段落开始里面该组,但结束外部的。hangparas
环境通过重新定义\everypar
来设置段落形状参数。这发生在组内,但 TeX 的段落构造使用段落结束时生效的设置。由于它在组外结束,因此组内的设置将丢失。您可以通过在命令之前开始段落来解决这个问题\href
:
\leavevmode\href{some://url.address}{This is a demonstration...}
任何开始段落的文本或命令都可以。如果可能的话,在组内结束段落也可以,但命令\href
不允许您这样做。
答案2
我现在没有时间看(这里是假期,我应该社交),但一个快速的解决方法是使用你自己的命令;例如:
\documentclass[12pt]{report}
\usepackage{breakurl}
\usepackage{hanging}
\usepackage[breaklinks]{hyperref}
\newcommand{\myhang}{\hangindent=0.25in\hangafter=1\noindent}
\begin{document}
\begin{hangparas}{0.25in}{1}
This is a demonstration that, normally, the hanging text mode will work perfectly, no matter what kind of silly text I put in it.
\href{http://google.com}{This is a demonstration that, normally, the hanging text mode will not work perfectly when I put some kind of URL inside it, and I
don't know why.}
\end{hangparas}
\bigskip % But this works:
\myhang This is a demonstration that, normally, the hanging text mode
will work perfectly, no matter what kind of silly text I put in it.
\myhang \href{http://google.com}{This is a demonstration that,
normally, the hanging text mode will work perfectly, no matter what
kind of silly text I put in it.}
\end{document}