# Tag Info

## Hot answers tagged urls

32

The following example uses hyperref (the question has mentioned "hyperlinking") and hooks into \hyper@linkurl to get the URLs. The catched URLs are written into an index file \jobname-url.idx: \urlentry{<hex coded URL>}{<page number>} The URL are hex encoded to avoid trouble with special characters. Package filecontents helps to create a ...

14

Atention: the following code works only for simple URLs, that is, URLs that do not contain special characters, like %. For a complete solution, please refer to Heiko's answer. As Nicola mentioned in the comments, redefining \url might be an interesting idea, but some characters in the URL might cause problems. Sadly my TeX-fu isn't good enough to ...

14

tex/xelatex/xetexurl/url.sty The old url.sty had used 8-bit characters that break with XeTeX's expectations of input encoded with UTF-8. Thus the file in tex/xelatex/xetexurl/url.sty is a patched version: % url.sty ver 3.1 15-Mar-2004 Donald Arseneau ... ... % Byte codes >= 0x80 replaced by ^^xx sequences - JK, 2006-04-07 Since version 3.3 ...

13

Define a special behavior for the slash: \documentclass{article} \usepackage{url} \makeatletter \def\Url@twoslashes{\mathchar\/\@ifnextchar/{\kern-.2em}{}} \g@addto@macro\UrlSpecials{\do\/{\Url@twoslashes}} \makeatother \begin{document} \urlstyle{sf}\url{http://tex.stackexchange.com/4427} \bigskip \urlstyle{rm}\url{http://tex.stackexchange.com} ...

12

The url package has a way how to do search-and-replace in the url strings. See the self-documented code. We tweak into \Url@acthash because it's called by \url exactly at the right place. \documentclass{article} \pagestyle{empty} \usepackage{url} \usepackage[T1]{fontenc} \usepackage{lmodern} \makeatletter % nice "//" ...

11

biblatex has a number of counters which when set to non-zero positive values less than 10000 allow breaks in urls in the bibliography. The specific counters are biburlnumpenalty biburlucpenalty biburllcpenalty for breaks after numbers, uppercase letters and lowercase letters, respectively. In your case it suffices to set the lowercase penalty to 9000; ...

10

The PDF format knows nested actions. hyperref supports this by option nextacrtionraw for \href in some rudimentary manner: \documentclass{article} \usepackage{hyperref} \begin{document} \href[% nextactionraw={% <<% /Type/Action% /S/URI% /URI(http://meta.tex.stackexchange.com/)% >>% }% ...

10

You can load the package url and redefine the command \url as follows: \DeclareUrlCommand\url{\color{magenta}\def\UrlLeft{http://}\urlstyle{tt}} Note that the xcolor package is required, too, if you want to give a color to the link. Now you can simply write \url{ipython.org} and http:// is added automatically. Complete example ...

9


8

It's better to use a different command, so that its usage is clear: \documentclass{article} \usepackage{xcolor} \usepackage[ colorlinks, linkcolor=magenta ]{hyperref} \newcommand\rurl[1]{% \href{http://#1}{\nolinkurl{#1}}% } \begin{document} This is a link \rurl{ipython.org} written in abbreviated form. \end{document} Of course you lose the tricks ...

7

I have seen/analyzed the problem some time ago. The reason is a buggy PDF viewer (some versions of AR), see giordano's comments. Package hyperref writes the URL into the PDF fil, e.g. pdfTeX or dvips/ps2pdf: /URI(http://www.phy.duke.edu/~rgb/Class/phy319/phy319/node75.html) The more canonical URI would be with percent encoding: ...

7

Hacking \UrlBreaks is not needed for \url inside the bibliography of biblatex. Package biblatex uses \biburlsetup and has already added lots of characters. The breaking at some character classes is controlled by counters. From the documentation of biblatex, "4.10.3 User-definable Lengths and Counters": biburlnumpenalty: If this counter is set to a value ...

7

The package biblatex loads the package url. The list of characters that allow line-breaks is given by \UrlBreaks and \UrlBigBreaks, which have the format \do\c for each character c. For more information read the documentation. The default setting of \UrlBreaks is \def\UrlBreaks{\do\.\do\@\do\\\do\/\do\!\do\_\do\|\do\;\do\>\do\]% ...

7

\documentclass{article} \usepackage{url} \makeatletter \g@addto@macro\UrlSpecials{\camelurl} \def\camelurl{% \count@a \loop \mathcode\count@"8000 \uccode\~\count@\uppercase{\edef~{\mathchar\the\count@\noexpand\breakifupper}}% \ifnum\count@<\z \advance\count@\@ne \repeat} \def\breakifupper#1{% \ifcat .\noexpand#1% \ifnum#1>40 \ifnum#1<91 ...

7

If biber is used as backend, then one can use the \DeclareSourcemap facilities to change fields. For the case at hand a solution is to remap url entries with dx.doi.org as initial part using the following code: \DeclareSourcemap{ \maps[datatype=bibtex]{ \map{ \step[ % copies url to doi field if it starts with http://dx.doi.org/ ...

7

If you are using the default Computer Modern Fonts, then the Latin Modern fonts might be an alternative, because they are derived from the Computer Modern Fonts. The tilde is lower. Also there is a proportionally spaced typewriter variant that might look better than the mono-spaced font for URLs. \documentclass{letter} \usepackage{url} ...

6

There are different approaches. First on LaTeX-level you can use \AtEveryCitekey{\clearfield{url}} \AtEveryBibitem works only for \printbibliography. Or you use a Biber solution: \DeclareSourcemap{ \maps[datatype=bibtex ]{ \map{ \step [ fieldset = url , null ] } } } MWE: \documentclass{article} \usepackage{filecontents} ...

6

The break points set by package url can be configured by setting \UrlBreakPenalty and \UrlBigBreakPenalty. A value of 10000 prevents the hyphenation: \documentclass[12pt,a4paper,oneside]{report} \usepackage{url} \usepackage{apacite} \usepackage[T1]{fontenc} \usepackage[osf]{libertine} \mathchardef\UrlBreakPenalty=10000 \mathchardef\UrlBigBreakPenalty=10000 ...

6

The following document generates some URLs, with and without percent encoding: \pdfobjcompresslevel=0 \documentclass{article} \usepackage{hyperref} \begin{document} \url{http://lyle.smu.edu/~tspell/jaws} \href{http://lyle.smu.edu/\%7Etspell/jaws}{% \nolinkurl{http://lyle.smu.edu/~tspell/jaws}% } \url{http://lyle.smu.edu/%7Etspell/jaws} \end{document} ...

6

I am not really sure how you envision things to work, nor am I convinced that there is a need for this. It seems (to me) more reasonable to first download the image to the local folder (rather than re-downloading for every run), with a filename of your choice rather being automatically derived based on the URL, and then just to include that. Here's a proof ...

6

An URL should not contain accented characters (cf. Uniform resource locator or RFC 3986). In your URL, replace accented characters by encoded characters: http://www.epe.gov.br/mercado/Documents/S%C3%A9rie%20Estudos%20de%20Energia/20130117_1.pdf Edit: Fast reference for encoded characters.

6

If biber is used as a backend the solution is to use \DeclareSourcemap to clean the url. \DeclareSourcemap{ \maps[datatype=bibtex]{ \map{ \step[fieldsource=url, match=\regexp{\\_}, replace=\regexp{_}] } } }

6

With backref active, the entire bibliography record in the .bbl file is read as an argument, so the category code tricks made by \url don't work. However, the IEEEtran bib style provides the hook \BIBdecl that's executed at the start of the bibliography; use it to make % into a printable character. The produced .bbl file shouldn't have comments after ...

6

One way to proceed is to create a modified version of the file plainnat.bst, in which the functions that format and print fields such as doi and isbn are reduced to stubs that do nothing: Find the file plainnat.bst in your TeX distribution. Make a copy of this file and call it, say, myplainnat.bst. (Don't edit an original file of the TeX distribution ...

5

Below an possible answer adapted to your usecase. For this solution I redefined \footnote and \href and used to if-statements. To really check if one is in a certain environment see this question. \documentclass{article} \usepackage{hyperref} \newif\ifprinted \printedtrue % for printet version % \printedfalse % for screen version \newif\iffoot \footfalse ...

5

You can prevent (or at least infinitely discourage) linebreaking in the footnote, which may or may not be suitable, depending. This produces a broken URL as you describe if you comment out the setting of \interfootnotelinepenalty. \documentclass{article} \setlength\textheight{3cm} \usepackage{hyperref} \def\a{One two three four. } \def\b{\a Five six seven ...

5


5

You're correct. The backslash is TeX's (default) escape character; it signals to TeX that what follows is different from "normal text". Therefore, simply typing \ will not produce a backslash in the output. (Incidentally, if you type \ followed by any amount of blank space, you will only produce a so-called control space, not a backslash.) To typeset a ...

5

The bibliography style you use, tJDE, does not recognize url fields in bibliography entries. Use the note field for that. The question marks stem from missing year fields that the style enforces even for misc entries (violating the standard). The question marks at the end stem from missing accessed fields that are required for misc entries (violating the ...

5

OK Inspired by Joseph Wright's idea of using lua for this i threw together an attempt at this in pure lua. \newcommand{\grabto}[2]{#2\ifluatex% \directlua 0 { local uri = "\luatexluaescapestring{#1}" local fname = "\luatexluaescapestring{#2}" local job = "\luatexluaescapestring{\jobname}" local file = io.open(fname, 'r') if file \string~= nil then ...

Only top voted, non community-wiki answers of a minimum length are eligible