GNOME Bugzilla – Bug 769977
How to link to an external URL with # (hash) sign?
Last modified: 2016-08-23 12:51:38 UTC
I am trying to link an `URL` which contains a `#` (hash) sign, see upstream code [here][1]: * http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_8.2.html#para_4bcb841e-c6bf-4e26-82a5-3fad3c942da0 Everything works as expected with `HTML` output, but things gets nasty with `LaTeX` output (`PDF`). It fails with: ! Illegal parameter number in definition of \Hy@tempa. <to be read again> p l.153 ...ageref{classgdcm_1_1ImageRegionReader}}{} ? Looking at the generated code, I see: \href{http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_8.2.html#para_4bcb841e-c6bf-4e26-82a5-3fad3c942da0} I cannot simply escape the `#` sign with a backslash since it would break the `HTML` output (but fix the `LaTeX` output). I found [on the web][2] that including `bigfoot` before `hyperref` can solve this sort of issue, but this did not work for me using the following trick in the doxyfile: @@ -1650,7 +1650,7 @@ PAPER_TYPE = letter # If left blank no extra packages will be included. # This tag requires that the tag GENERATE_LATEX is set to YES. -EXTRA_PACKAGES = +EXTRA_PACKAGES = bigfoot # The LATEX_HEADER tag can be used to specify a personal LaTeX header for the # generated LaTeX document. The header should contain everything until the first Is there anything simple to include a URL with `#` sign that works for both `HTML` and `LaTeX` output ? --- EDIT: I found out that doxygen generate the following code: % Hyperlinks (required, but should be loaded last) \usepackage{ifpdf} \ifpdf \usepackage[pdftex,pagebackref=true]{hyperref} \else \usepackage[ps2pdf,pagebackref=true]{hyperref} \fi So I cannot explicitly `\usepackage{hyperref}` after `\usepackage{bigfoot}` since this creates some sort of conflict. Package hyperref Message: Driver (autodetected): hpdftex. (/usr/share/texlive/texmf-dist/tex/latex/hyperref/hpdftex.def (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty)) ! LaTeX Error: Option clash for package hyperref. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.101 \else [1]: https://github.com/malaterre/GDCM/blob/master/Source/MediaStorageAndFileFormat/gdcmImageRegionReader.h#L31 [2]: http://tex.stackexchange.com/a/12860/25980
The doxyfile can be found online here: https://github.com/malaterre/GDCM/blob/master/Utilities/doxygen/doxyfile.in There is a single doxyfile for both the HTML output and the LaTeX output.
I tool gdcmImageRegionReader.h and renamed it to aa.h and from the Doxyfile.in I removed all @GDCM... I ran on Windows with doxygen version 1.8.11 and MikTex 2.9 and had no problems. I didn't have any problems with 1.8.9.1 either Which version of texlive are you using? Can you please attach a self-contained example (source+config file in a tar or zip) that allows us to reproduce the problem, other sources might change and it wouldn't be possible to reproduce the problem anymore.
I am running debian/sid (Linux). Here are the version I have: $ doxygen --version 1.8.11 If I copy the header file and the doxygen file (removing all @GDCM stuff), here is what I get: $ make rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf pdflatex refman This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode (./refman.tex LaTeX2e <2016/03/31> patch level 3 Babel <3.9r> and hyphenation patterns for 3 language(s) loaded. (/usr/share/texlive/texmf-dist/tex/latex/base/book.cls Document Class: book 2014/09/29 v1.4h Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/bk10.clo)) (/usr/share/texlive/texmf-dist/tex/latex/base/fixltx2e.sty Package fixltx2e Warning: fixltx2e is not required with releases after 2015 (fixltx2e) All fixes are now in the LaTeX kernel. (fixltx2e) See the latexrelease package for details. ) (/usr/share/texlive/texmf-dist/tex/latex/tools/calc.sty) (./doxygen.sty (/usr/share/texlive/texmf-dist/tex/latex/base/alltt.sty) (/usr/share/texlive/texmf-dist/tex/latex/tools/array.sty) (/usr/share/texlive/texmf-dist/tex/latex/float/float.sty) (/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty) (/usr/share/texlive/texmf-dist/tex/latex/tools/verbatim.sty) (/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty (/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg) (/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)) (/usr/share/texlive/texmf-dist/tex/latex/colortbl/colortbl.sty)) (/usr/share/texlive/texmf-dist/tex/latex/tools/longtable.sty) (/usr/share/texlive/texmf-dist/tex/latex/tabu/tabu.sty (/usr/share/texlive/texmf-dist/tex/latex/varwidth/varwidth.sty)) (/usr/share/texlive/texmf-dist/tex/latex/tools/tabularx.sty) (/usr/share/texlive/texmf-dist/tex/latex/multirow/multirow.sty)) (/usr/share/texlive/texmf-dist/tex/latex/adjustbox/adjustbox.sty (/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xkeyval.sty (/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkeyval.tex (/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkvutils.tex (/usr/share/texlive/texmf-dist/tex/generic/xkeyval/keyval.tex)))) (/usr/share/texlive/texmf-dist/tex/latex/adjustbox/adjcalc.sty) (/usr/share/texlive/texmf-dist/tex/latex/adjustbox/trimclip.sty (/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty (/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty (/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty) (/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg))) (/usr/share/texlive/texmf-dist/tex/latex/collectbox/collectbox.sty) (/usr/share/texlive/texmf-dist/tex/latex/adjustbox/tc-pdftex.def)) (/usr/share/texlive/texmf-dist/tex/latex/ifoddpage/ifoddpage.sty)) (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty (/usr/share/texlive/texmf-dist/tex/latex/base/utf8.def (/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.dfu) (/usr/share/texlive/texmf-dist/tex/latex/base/ot1enc.dfu) (/usr/share/texlive/texmf-dist/tex/latex/base/omsenc.dfu))) (/usr/share/texlive/texmf-dist/tex/latex/base/makeidx.sty) (/usr/share/texlive/texmf-dist/tex/latex/tools/multicol.sty) (/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty (/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def (/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.dfu))) (/usr/share/texlive/texmf-dist/tex/latex/wasysym/wasysym.sty) (/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty (/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.def)) (/usr/share/texlive/texmf-dist/tex/latex/psnfss/helvet.sty) (/usr/share/texlive/texmf-dist/tex/latex/psnfss/courier.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (/usr/share/texlive/texmf-dist/tex/latex/sectsty/sectsty.sty) (/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty) (/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)) Writing index file refman.idx (/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty)) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/auxhook.sty) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty) (/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def) (/usr/share/texlive/texmf-dist/tex/latex/latexconfig/hyperref.cfg) (/usr/share/texlive/texmf-dist/tex/latex/hyperref/backref.sty (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty)) (/usr/share/texlive/texmf-dist/tex/latex/url/url.sty)) Package hyperref Message: Driver: hpdftex. (/usr/share/texlive/texmf-dist/tex/latex/hyperref/hpdftex.def) (/usr/share/texlive/texmf-dist/tex/latex/hyperref/puenc.def) (/usr/share/texlive/texmf-dist/tex/latex/caption/caption.sty (/usr/share/texlive/texmf-dist/tex/latex/caption/caption3.sty) (/usr/share/texlive/texmf-dist/tex/latex/caption/ltcaption.sty)) No file refman.aux. (/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd) (/usr/share/texlive/texmf-dist/tex/latex/psnfss/t1phv.fd) (/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii [Loading MPS to PDF converter (version 2006.09.02).] ) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty) (/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)) *geometry* driver: auto-detecting *geometry* detected driver: pdftex (/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/gettitlestring.sty)) (/usr/share/texlive/texmf-dist/tex/latex/wasysym/uwasy.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd) [1{/var/lib/texmf/fo nts/map/pdftex/updmap/pdftex.map}] [2] [3] [4] Chapter 1. (./namespaces.tex LaTeX Warning: Reference `namespacegdcm' on page 1 undefined on input line 3. ) [1] [2] Chapter 2. (./hierarchy.tex LaTeX Warning: Reference `classgdcm_1_1ImageRegionReader' on page 3 undefined o n input line 4. ) [3] [4] Chapter 3. (./annotated.tex ! Illegal parameter number in definition of \Hy@tempa. <to be read again> p l.3 ...\pageref{classgdcm_1_1ImageRegionReader}}{} ? q OK, entering \batchmodeMakefile:6: recipe for target 'refman.pdf' failed
The issue is (IMHO) here: [...] latex/annotated.tex:\item\contentsline{section}{\hyperlink{classgdcm_1_1ImageRegionReader}{gdcm\+::\+Image\+Region\+Reader} \\*\hyperlink{classgdcm_1_1ImageRegionReader}{Image\+Region\+Reader} This class is able to read a region from a D\+I\+C\+OM file containing an image. This implementation requires that the information stored in the D\+I\+C\+OM header are consistent with what is in the encapsulated Pixel Data. This is technically not required by D\+I\+C\+OM standard, which makes this implementation illegal with regards to the famous J\+P\+EG note\+: \href{http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_8.2.html#para_4bcb841e-c6bf-4e26-82a5-3fad3c942da0}{\tt http\+://dicom.\+nema.\+org/medical/dicom/current/output/chtml/part05/sect\+\_\+8.\+2.\+html\#para\+\_\+4bcb841e-\/c6bf-\/4e26-\/82a5-\/3fad3c942da0} }{\pageref{classgdcm_1_1ImageRegionReader}}{} [...] I have no idea why you dont get the \href with the '#' sign on windows.
Just to state the obvious, changing in the generated tex file: \href{http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_8.2.html#para_4bcb841e-c6bf-4e26-82a5-3fad3c942da0}{\tt into: \href{http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_8.2.html\#para_4bcb841e-c6bf-4e26-82a5-3fad3c942da0}{\tt does fix the issue for me...
From the hyperref manual: If you need to make references to URLs, or write explicit links, the following low-level user macros are provided: \href[options]{URL}{text} The text is made a hyperlink to the URL; this must be a full URL (relative to the base URL, if that is defined). The special characters # and ˜ do not need to be escaped in any way. I've just tried it on a Red Hat Enterprise Linux 6 system with Tex Live 2014 and I didn't have problems. Seen the above I'm a bit reluctant in fixing this.
Here is what a TeX expert reports: [...] Hi Mathieu, > Here is my attempt to minimize the issue (extracted from src:gdcm Well, not really minimal, here is a really minimal one: \documentclass{article} \usepackage{hyperref} \begin{document} \contentsline{section}{note: \href{http://a.b.c/d#EEE}{link} }{}{} \end{document} Did this *ever* work before, or did doxygen introduce something new here and started to insert href entries in contentlines? The problem is nameref.sty that is loaded and tries to link names of section. The inclusion of a \href in a \contentsline looks problematic, thus. TOC entries are already links to the respective sections in the document. Now if you add a "link within the link" this will not work, and can anyway not reasonably work. I still stand by that this is a bug in doxygen, it should not include href stuff in the contentsline code. Anyway, I have opened an issue at the hyperref github page, see above BTS code. All the best Norbert [...]
It is the responsibility of the package maintainers of GDCM how they want to code and document their code, but looking at the code and the result of the problematic documentation part: /** * \brief ImageRegionReader * This class is able to read a region from a DICOM file containing an image. This implementation * requires that the information stored in the DICOM header are consistent with what is in the * encapsulated Pixel Data. This is technically not required by DICOM standard, which makes * this implementation illegal with regards to the famous JPEG note: * http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_8.2.html#para_4bcb841e-c6bf-4e26-82a5-3fad3c942da0 * \see ImageReader */ and the result in annotated.tex it looks to me that the "brief" description is not a "brief" description but a "brief" plus "detailed" description. My suggestion is either to set the JAVADOC_AUTOBRIEF to YES or to reformulate the comment block to e.g.: /** * \brief This class is able to read a region from a DICOM file containing an image. * \details This implementation * requires that the information stored in the DICOM header are consistent with what is in the * encapsulated Pixel Data. This is technically not required by DICOM standard, which makes * this implementation illegal with regards to the famous JPEG note: * http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_8.2.html#para_4bcb841e-c6bf-4e26-82a5-3fad3c942da0 * \see ImageReader */
> it looks to me that the "brief" description is not a "brief" description but a "brief" plus "detailed" description. indeed. closing as invalid.