0

I add \href in \subsection{}, this make the url become all capital, how can I deal with this?

For example, I use \subsection{\href{http://finance.sina.com.cn/roll/2018-06-30/doc-iheqpwqz3115534.shtml}{some text}} and run latex, it shows like this. enter image description here And It contains an url.

Then when I click the link, the url becomes http://finance.sina.com.cn/ROLL/2018-06-30/DOC-IHEQPWQZ3115534.SHTML like this: enter image description here in the web-browser. All the letters become capital, this url cannot open the right website.

What can I do to fix this? I want the url can open the right website. Thank you.

  • 1
    Copying the example in your post body, I do not replicate the behaviour you describe. Please could you produce a Minimum Working Example which reproduces the problem? – preferred_anon Jul 6 '18 at 7:36
  • An example that could reproduce this is \documentclass[british]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{babel} \usepackage{hyperref} \begin{document} \MakeUppercase{\href{http://example.com/lowercase}{some text}} \uppercase{\href{http://example.com/lowercase}{some text}} \end{document} – moewe Jul 7 '18 at 12:21
  • 1
    Maybe tex.stackexchange.com/q/274734/35864 can help – moewe Jul 7 '18 at 12:22
  • The work-around in the linked question seems to work here is well, \documentclass[british]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{babel} \usepackage{hyperref} \protected\def\mylink{http://example.com/lowercase} \begin{document} \MakeUppercase{\href{\mylink}{some text}} \uppercase{\href{\mylink}{some text}} \end{document} but maybe there is something cleverer. – moewe Jul 7 '18 at 12:24
  • Sir, but if you use \href in \subsection{} like \subseciont{\href{}{}}, all the letters will become upper case. – Felix LL Jul 7 '18 at 12:45
0

Something like this will work! :- \subsection{\texorpdfstring{\lowercase{\href{http://finance.sina.com.cn/roll/2018-06-30/doc-iheqpwqz3115534.shtml}{\MakeUppercase{some text}}}}{}}

Since by default, the whole text in a subsection is in upper-case, hence after wrapping \lowercase over whole \href part, this upper-case has to be done forcefully (here using \MakeUppercase).

Also, \texorpdfstring has been used to avoid the warning:
Hyperref warning - Token not allowed in a PDF string

(There may be other work-arounds too)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.