LaTeX 使用 bib 管理参考文献时,引用网络资源 URL 导致排版难看的问题

Example usage

In the preamble:

\usepackage{url}

%% Define a new 'leo' style for the package that will use a smaller font.
\makeatletter
\def\url@leostyle{%
  \@ifundefined{selectfont}{\def\UrlFont{\sf}}{\def\UrlFont{\small\ttfamily}}}
\makeatother
%% Now actually use the newly defined style.
\urlstyle{leo}

In a BibTeX entry:

@misc{
    c.elmohamed,
    author = "Saleh Elmohamed",
    title = "Examples in {H}igh {P}erformance {F}ortran",
    howpublished = "Website",
    year = {1996},
    note = {\url{http://www.npac.syr.edu/projects/
                    cpsedu/summer98summary/ examples/hpf/hpf.html}}
}


Result, before

'Before' screenshot

Result, after

'After' screenshot

Things to watch out for

I tweak the default url style to use a smaller version of the typewriter font because I otherwise find that the Adobe Courier font I use (see also the Using Courier tip) displays a bit too large for my tastes, but also because the larger font still causes more spacing ugliness (in terms of underfull hboxes), as illustrated by the following screenshot:

'After'
screenshot

If strange ‘%’ signs start appearing in the list of references in the bibliography section, this is because BibTeX inserts those when it encounters a line it feels is too long:

'After'
screenshot

This is purely a BibTeX thing: inside a URL being handled by the url package, the line won't actually be too long — after all the whole idea is for url to be responsible for splitting it. The solution, as shown in the listing given earlier, is to add some stray whitespace to the long url. BibTeX will then no longer think the line is too long, and \url{} ignores all whitespace anyway, so it will not appear in the output.

The biggest problem with the url package is that you do not use it in your LaTeX source file, but in your BibTeX source files, thus making your bibliographies non-portable: once you start using \url{} in your BibTeX entries, you will be forced to include the url package in all your LaTeX files that use that bibliography file.



 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值