Text FormattingHash in a URL

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
ac10
Posts: 13
Joined: Wed Dec 29, 2010 3:01 pm

Hash in a URL

Post by ac10 »

Hello everyone,

I'm trying to use a hash symbol as part of a url. I want the url to be clickable so \# doesn't work. It cuts everything after it out of the url.

I tried putting it in math mode, but that didn't work either.

I get this error - You can't use `macro parameter character #' in horizontal mode.

This is my header....

Code: Select all

\documentclass{book}
\pagestyle{empty}
\usepackage[margin=1in]{geometry}                  
\geometry{a4paper,margin=1in,} 
\usepackage{url}   
Thanks very much for your help.
Last edited by ac10 on Sat Dec 17, 2011 4:59 pm, edited 1 time in total.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Hash in a URL

Post by Stefan Kottwitz »

To get a clickable URL, you should load the hyperref package in addition:

Code: Select all

\usepackage{hyperref}
Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Hash in a URL

Post by localghost »

An adequate problem description would contain a minimal example.

Code: Select all

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}

\begin{document}
  \url{http://mirror.ctan.org/info/latex2e-help-texinfo/latex2e.html#toc-Overview-of-LaTeX-1}
\end{document}

Thorsten
Post Reply