Graphics, Figures & TablesSome combo of href with # in URL, tabularx etc causes errors

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jafingerhut
Posts: 1
Joined: Sun Feb 20, 2011 12:06 am

Some combo of href with # in URL, tabularx etc causes errors

Post by jafingerhut »

I have a LaTeX source file that produces a nice visual layout that I like, and want to keep. I want to be able to generate a PDF file with links to external URLs, and ideally also an HTML file with similar visual appearance and the same links, automatically generated from that LaTeX source file, if possible.

A file that is nearly the same as the original file has been uploaded as an attachment called latex-community-question-2-href-error.tex

If you replace the \href{ ... }{ ... } in that file with just zero?, you will have the original file, which has no errors during LaTeX processing, and using dvipdfm produces a nice PDF file, but with no links.

If you keep the file as is, latex gives an error near the } that closes the \colouredbox{grey}{ ... } around the \href.

While experimenting, I have found that if you remove the # from the URL, latex gives no errors, and dvipdfm produces a PDF file with a link, but of course it is not the link I want. But at least it can make some kind of link.

If I remove the \colouredbox{ }, the \tabularx (and the & symbols that were in the \tabularx), the \cmd, and the \frenchspacing from around the \href, latex gives no errors and I can produce a PDF file with the desired link, but then the visual layout is completely changed to something I don't want.

I've tried variations with \protect in a few places near the \href, but without any success.

Does anyone know a way to keep the combination of visual formatting, and URLs with # using hyperref?

Is there another package besides hyperref I should try?

Thanks for any help you can provide.
Attachments
latex-community-question-2-href-error.tex
(14.49 KiB) Downloaded 249 times

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

5gon12eder
Posts: 126
Joined: Sun Feb 13, 2011 8:36 pm

Some combo of href with # in URL, tabularx etc causes errors

Post by 5gon12eder »

Escape the # by using \# instead. If I do so, the document is typeset correctly and the hyperlink works.
I'm using pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian).
Post Reply