TransWikia.com

Symbol for external links

TeX - LaTeX Asked by Elmar Zander on January 9, 2021

I’m using the hyperref package in my document to provide hyperlinks to external documents. However, I don’t want to have the links coloured or underlined, because I find this usually ugly and distracting. What I would rather like is a little symbol beside the link text to provide a small hint for the reader that there is something clickable. What I have in mind is something like the little symbol constisting of a small square and an arrow you can find e.g. in Wikipedia for external links. Is there any package or font that provides such a symbol or do I have to brew one myself?

5 Answers

I'm using TikZ to draw the symbol:

documentclass{article}
usepackage{tikz}

newcommand{ExternalLink}{%
    tikz[x=1.2ex, y=1.2ex, baseline=-0.05ex]{% 
        begin{scope}[x=1ex, y=1ex]
            clip (-0.1,-0.1) 
                --++ (-0, 1.2) 
                --++ (0.6, 0) 
                --++ (0, -0.6) 
                --++ (0.6, 0) 
                --++ (0, -1);
            path[draw, 
                line width = 0.5, 
                rounded corners=0.5] 
                (0,0) rectangle (1,1);
        end{scope}
        path[draw, line width = 0.5] (0.5, 0.5) 
            -- (1, 1);
        path[draw, line width = 0.5] (0.6, 1) 
            -- (1, 1) -- (1, 0.6);
        }
    }

begin{document}
See Wikipedia ExternalLink for more information.
end{document}

enter image description here

Correct answer by omisson on January 9, 2021

Maybe the following is useful.

Code

Either

documentclass{article}

usepackage{bbding}
usepackage[pdfborder={0 0 0}]{hyperref}

newcommand*link[2]{%
  href{#1}{#2},raisebox{-1pt}{footnotesizeFourStarOpen}%
}

begin{document}

Click link{http://www.latex-project.org/}{here} to go to the webpage.

end{document}

or

documentclass{article}

usepackage{bbding}
usepackage[pdfborder={0 0 0}]{hyperref}

newcommand*link[2]{%
  href{#1}{#2},{scriptsizeFourStarOpen}%
}

begin{document}

Click link{http://www.latex-project.org/}{here} to go to the webpage.

end{document}

will do the job.

Output (for the first MWE)

enter image description here

Answered by Svend Tveskæg on January 9, 2021

In addition to Svend Mortensen’s answer, too long for a comment.

For Xe(La)TeX or Lua(La)TeX see also update below.

If you already set a document with a lot of hrefin it, you also can redefine the hrefcommand by copying the original macro to a new one with let (works here, but not in every case!), see my example.

Note, that I used a dedicated hyperref option for hiding the links. I also show some symbols from two dingbat fonts. Fonts of this type should be in general the most useful for your need.

documentclass{article}

usepackage{bbding,pifont} % two dingbat fonts

usepackage{graphicx} % "graphics" would be enough for the minimal example

usepackage[hidelinks]{hyperref}

% Redefinition:
letorighrefhref
renewcommand{href}[2]{orighref{#1}{#2},ArrowBoldUpRight} %bbding
% the same with symbol included in link:
% renewcommand{href}[2]{orighref{#1}{#2,ArrowBoldUpRight}}

% Examples:
newcommand{hrefa}[1]{orighref{http://example.com/}{#1},scalebox{0.75}{ArrowBoldUpRight}} %bbding
newcommand{hrefb}[1]{orighref{http://example.com/}{#1},ding{230}} %pifont
newcommand{hrefc}[1]{raisebox{-0.4ex}{HandRight},orighref{http://example.com/}{#1}} %bbding
newcommand{hrefd}[1]{scalebox{1.3}{raisebox{-0.3ex}{ding{43}}},orighref{http://example.com/}{#1}} %pifont
newcommand{hrefe}[1]{scalebox{0.8}{raisebox{-0.5ex}{HandRightUp}},orighref{http://example.com/}{#1}} %bbding
newcommand{hreff}[1]{ding{226},orighref{http://example.com/}{#1}} %pifont
newcommand{hrefg}[1]{ding{238},orighref{http://example.com/}{#1}} %pifont
% the last with symbol included in link:
% newcommand{hrefg}[1]{orighref{http://example.com/}{ding{238},#1}} %pifont

begin{document}

hrefa{link A}, hrefb{link B},

hrefc{link C}, hrefd{link D}, hrefe{link E}, hreff{link F}, hrefg{link G}

end{document}

LaTeX example output


Update:

Bad timing – shortly after writing of this answer a new package fontawesome was released. For Xe(La)TeX or Lua(La)TeX users this package “grants access to 249 web-related icons provided by the included Font Awesome free font” (cite from documentation abstract). One of them is the symbol for external links accessible with faicon{external-link} or faExternalLink:

% Compile with LuaLaTeX or XeLaTeX
documentclass{article}
usepackage{fontawesome}
usepackage[hidelinks]{hyperref}

% Redefinition, symbol included in link:
letorighrefhref
renewcommand{href}[2]{orighref{#1}{#2,faExternalLink}}

begin{document}
href{http://example.com}{example web site}
end{document}

LuaLaTeX/XeLaTeX output example

Answered by Speravir on January 9, 2021

Another idea:

documentclass{standalone}
usepackage{txfonts}
usepackage{graphicx}
defxLink{$!vcenter{hbox{rotatebox{45}{$DiamondRight$}}}!!$}
begin{document}
See WikipediaxLink for details about this logo.
end{document}

Result

Answered by JLDiaz on January 9, 2021

One can simply use the ExternalLink icon in the fontawesome package

documentclass{article}
usepackage{hyperref}
RequirePackage{fontawesome}
begin{document}
href{https://stackexchange.com/}{Link to Home page faExternalLink}
end{document}

output:

faExternalLink_example

Answered by Ketan on January 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP