1

using package verbatimbox one can use target (second argument) of href as verbatimbox. But I am trying to use the version with no box.

I found some issue when using the boxed version. Here is an example showing the problem first, and then showing my attempts at using the no boxed version

\documentclass[12pt,notitlepage]{article}
\usepackage{hyperref}
\usepackage{verbatimbox}
    
%code thanks to 
%https://tex.stackexchange.com/questions/697506/why-unable-to-recall-verbbox-from-vebatimbox-package-in-enumeration-list
\newcommand{\theverbboxitem}{%
  \kern-\labelwidth\kern-\labelsep
  \theverbbox
  \kern\labelwidth\kern\labelsep
}

\begin{document} 

\begin{enumerate}
\item \leavevmode\begin{verbbox}7_Inverse_hyperbolic_functions/7.1_Inverse_hyperbolic_sine/186_7.1.2-d_x-^m-a+b_arcsinh-c_x-^n\end{verbbox}
      \href{https://some_url_1/report.htm}{\theverbboxitem}
\item \leavevmode\begin{verbbox}7_Inverse_hyperbolic_functions/7.2_Inverse_hyperbolic_sine/186_7.1.2-d_x-^m-a+sin_x_y+b_arcsinh-c_x-^n\end{verbbox}
      \href{https://some_url_2/report.htm}{\theverbboxitem}
\end{enumerate}
\end{document}

Compiled using lualatex gives

enter image description here

It wraps there at the end. Which I do not want. I thought it is due to using the box.

Here is also a screen shot from large document I build showing the problem

enter image description here

I was trying to see if I can have version without the boxes, it will not do that.

It turned out the package provide a noboxed version! But I am not able to figure how to use the no boxed version. When I try

\begin{verbnobox}my nice site\end{verbnobox}
\href{https://site_URL_here/index.htm}{\theverbbox}

I get

enter image description here

The above is not an href. clicking on it does nothing. the dot below is empty box. I understand what is going on. But can't figure how to make no boxed version work same as boxed version in href.

Doc says

enter image description here

Ok, so I can't recall them using \theverbbox. But then how to use them with href? I tried using it directly

\href{https://site_URL_here/index.htm}{\begin{verbnobox}my nice site\end{verbnobox}}

But got compile error.

Missing } inserted. ...begin{verbnobox}my nice site\end{verbnobox}}

My question is: How to use verbnobox instead of verbbox as second argument of href if one can't recall it and can't insert it directly? I basically just want a way to use Verbatim as second argument of href. The above package does this, but I do not want the box around it in order to fix the wrapping shown in the above example.

here is MWE

\documentclass[12pt,notitlepage]{article}
\usepackage{hyperref}
\usepackage{verbatimbox}
    
\begin{document} 

\begin{verbnobox}my nice site\end{verbnobox}
\href{https://site_URL_here/index.htm}{\theverbbox} %not correct

%this is also not correct
%\href{https://site_URL_here/index.htm}{\begin{verbnobox}my nice site\end{verbnobox}}

\end{document}

TL 2023

1 Answer 1

2

I don't think that verbatimbox is a good solution. You get a box and that means no sensible line break. I would use \urldef to store an url like text:

\documentclass[12pt,notitlepage]{article}
\usepackage{hyperref}
\usepackage{verbatimbox}
\textwidth=4cm
\usepackage{xurl}
\begin{document} 
\begin{myverbbox}{\myTarget}https://some_url_with_^many_%*?_strange_characters/report.htm\end{myverbbox}

\href{https://some_url_with_^many_%*?_strange_characters/report.htm}{\myTarget}

\bigskip

\urldef\mytarget\nolinkurl{https://some_url_with_^many_%*?_#strange_characters/report.htm}
\href{https://some_url_with_^many_%*?_strange_characters/report.htm}{\mytarget}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .