Text FormattingPercent Sign as a String Character

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
StevoSn
Posts: 4
Joined: Wed Jul 07, 2010 1:33 pm

Percent Sign as a String Character

Post by StevoSn »

Hey,

I wanted to use a hyper link in my document that contains a percentage sign. I included the hyperref package and then tried this.

Code: Select all

\href{url://to.some_stupid%C3%BC_named.file}{some text}
But that doesn't work. Is there a way to define a fixed string in LaTeX?


Cheers!
Stevo

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Percent Sign as a String Character

Post by localghost »

The hyperref manual (Section 4 — Additional user macros, p. 12ff) suggests to use the \nolinkurl command just to format the URL as text. Then an according combination should do the trick.

Code: Select all

\href{\nolinkurl{http://domain.org/expression%20with%20blank%20spaces}}{The link Text}
Untested due to a missing minimal example.


Thorsten
StevoSn
Posts: 4
Joined: Wed Jul 07, 2010 1:33 pm

Percent Sign as a String Character

Post by StevoSn »

Sorry,
it seems to work without any \nolinkurl...

the problem seems to only occur when I use the \href{}{} command inside a \caption environment, such as:

Code: Select all


\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{graphicx}
\usepackage{hyperref}
\begin{document}
text... and as you can see when using
\begin{figure}[htb]
\begin{center}
\leavevmode
\fbox{
\includegraphics[width=0.95\textwidth]{./figs/oxygen} }
\end{center}
\caption{
\href{http://commons.wikimedia.org/wiki/File:Molek\%C3\%BClorbital-Sauerstoff.png}{this link}, blabla}
\end{figure}
some more text
\end{document}
here I had to put a back-slash in front of the % sign.

Whereas

Code: Select all

\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{hyperref}
\begin{document}
text... and as you can see when using
\href{http://commons.wikimedia.org/wiki/File:Molek%C3%BClorbital-Sauerstoff.png}{this link}
some more text
\end{document}
did work without it..

:roll:

Anyway, thanks for your help!
Cheers!
Stevo
Michael Schmid
Posts: 2
Joined: Wed Sep 05, 2012 4:53 pm

Percent Sign as a String Character

Post by Michael Schmid »

You can also use the escape character \ (backslash):

Code: Select all

\href{url://to.some_stupid\%C3\%BC_named.file}{some text}
Post Reply