1

I use \urldef in order to make href, because the names are folder/file path which can contain many different strange characters.

This works fine in PDF with lualatex. But I noticed that the HTML generated by tex4ht breaks the names into two lines, which causes BLANK space to show in the name when looking at it on the screen. For some reason it does not keep the long name on one line.

This makes it hard to read. I want the name to not contain extra spaces.

Here is MWE

\documentclass[12pt,oneside]{book}
\usepackage{hyperref} 
\usepackage{url}

\begin{document}

\section{Tests completed}
\begin{enumerate}
\item \urldef\mytarget\nolinkurl{test_cases/rubi_tests/0_Independent_test_suites/1_Apostol_Problems}
\href{test_cases/rubi_tests/0_Independent_test_suites/1_Apostol_Problems/output/report.htm}{\mytarget} \hspace{5pt}  [175]
\item \urldef\mytarget\nolinkurl{test_cases/rubi_tests/0_Independent_test_suites/2_Bondarenko_Problems}
\href{test_cases/rubi_tests/0_Independent_test_suites/2_Bondarenko_Problems/output/report.htm}{\mytarget} \hspace{5pt}  [35]
\end{enumerate}
\end{document}

When compiled using

make4ht -ulm default -a debug  index.tex "mathjax,htm,nostyle"

It gives

enter image description here

The reason this happens is because tex4ht breaks the name when it sees _ or at random place. or may be after certain length is reached?. If so, is there a way to remove this limit and keep the name on one line regardless of how long it is?

Here is the raw html

<!DOCTYPE html> 
<html lang='en-US' xml:lang='en-US'> 
<head><title></title> 
<meta charset='utf-8' /> 
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' /> 
<meta content='width=device-width,initial-scale=1' name='viewport' /> 
<link href='index.css' rel='stylesheet' type='text/css' /> 
<meta content='index.tex' name='src' /> 
<script>window.MathJax = { tex: { tags: "ams", }, }; </script> 
 <script async='async' id='MathJax-script' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js' type='text/javascript'></script>  
</head><body> 
<h3 class='sectionHead' id='tests-completed'><span class='titlemark'>0.1   </span> <a id='x1-10000.1'></a>Tests completed</h3>
<!-- l. 9 --><p class='noindent'>      
</p>
<ol class='enumerate1'>
<li class='enumerate' id='x1-1002x1'>             <a href='test_cases/rubi_tests/0_Independent_test_suites/1_Apostol_Problems/output/report.htm'><span class='ec-lmtt-12'>test_cases/rubi_tests/0_Independent_test_suites/1_
Apostol_Problems</span></a>  [175]
</li>
<li class='enumerate' id='x1-1004x2'>             <a href='test_cases/rubi_tests/0_Independent_test_suites/2_Bondarenko_Problems/output/report.htm'><span class='ec-lmtt-12'>test_cases/rubi_tests/0_Independent_test_suites/2_
Bondarenko_Problems</span></a>  [35]</li></ol>
 
</body> 
</html>

If I edit the index.htm by hand and make the name one long line by removing the extra CR it added, the HTML now becomes

<!DOCTYPE html> 
<html lang='en-US' xml:lang='en-US'> 
<head><title></title> 
<meta charset='utf-8' /> 
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' /> 
<meta content='width=device-width,initial-scale=1' name='viewport' /> 
<link href='index.css' rel='stylesheet' type='text/css' /> 
<meta content='index.tex' name='src' /> 
<script>window.MathJax = { tex: { tags: "ams", }, }; </script> 
 <script async='async' id='MathJax-script' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js' type='text/javascript'></script>  
</head><body> 
<h3 class='sectionHead' id='tests-completed'><span class='titlemark'>0.1   </span> <a id='x1-10000.1'></a>Tests completed</h3>
<!-- l. 9 --><p class='noindent'>      
</p>
<ol class='enumerate1'>
<li class='enumerate' id='x1-1002x1'>             <a href='test_cases/rubi_tests/0_Independent_test_suites/1_Apostol_Problems/output/report.htm'><span class='ec-lmtt-12'>test_cases/rubi_tests/0_Independent_test_suites/1_Apostol_Problems</span></a>  [175]
</li>
<li class='enumerate' id='x1-1004x2'>             <a href='test_cases/rubi_tests/0_Independent_test_suites/2_Bondarenko_Problems/output/report.htm'><span class='ec-lmtt-12'>test_cases/rubi_tests/0_Independent_test_suites/2_Bondarenko_Problems</span></a>  [35]</li></ol>
 
</body> 
</html>

and on screen it now looks like this, which is what is expected.

enter image description here

How to fix tex4ht so it does not break long names in href and keep the name on same line? Notice that all links work fine. There are no problems with the link. It is just the display of the long names which is the problem.

TL 2023 installed few days ago on Linux.

Update

I found more serious problems with this. Look at this MWE

\documentclass[12pt,oneside]{book}
\usepackage{hyperref} 
\usepackage{url}

\begin{document}

\section{Tests completed}
\begin{enumerate}
\item \urldef\mytarget\nolinkurl{test_cases/rubi_tests/1_Algebraic_functions/1.1_Binomial/1.1.1_Linear_binomial/27_1.1.1.7P[x](a+bx)^m(c+dx)^n(e+fx)^p}
\href{test_cases/rubi_tests/1_Algebraic_functions/1.1_Binomial/1.1.1_Linear_binomial/27_1.1.1.7P[x](a+bx)^m(c+dx)^n(e+fx)^p/output/report.htm}{\mytarget} \hspace{5pt}  [100]
\item \urldef\mytarget\nolinkurl{test_cases/rubi_tests/1_Algebraic_functions/1.1_Binomial/1.1.1_Linear_binomial/28_1.1.1.8P[x](a+bx)^m(c+dx)^n(e+fx)^p(g+hx)^q}
\href{test_cases/rubi_tests/1_Algebraic_functions/1.1_Binomial/1.1.1_Linear_binomial/28_1.1.1.8P[x](a+bx)^m(c+dx)^n(e+fx)^p(g+hx)^q/output/report.htm}{\mytarget} \hspace{5pt}  [43]
\end{enumerate}
\end{document}

PDF gives

enter image description here

But compiled with tex4ht using same command above shows this web page

enter image description here

Completely mangled up and big mess. The raw HTML for the above is

<!DOCTYPE html> 
<html lang='en-US' xml:lang='en-US'> 
<head><title></title> 
<meta charset='utf-8' /> 
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' /> 
<meta content='width=device-width,initial-scale=1' name='viewport' /> 
<link href='index.css' rel='stylesheet' type='text/css' /> 
<meta content='index.tex' name='src' /> 
<script>window.MathJax = { tex: { tags: "ams", }, }; </script> 
 <script async='async' id='MathJax-script' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js' type='text/javascript'></script>  
</head><body> 
<h3 class='sectionHead' id='tests-completed'><span class='titlemark'>0.1   </span> <a id='x1-10000.1'></a>Tests completed</h3>
<!-- l. 9 --><p class='noindent'>      
</p>
<ol class='enumerate1'>
<li class='enumerate' id='x1-1002x1'>    <a href='test_cases/rubi_tests/1_Algebraic_functions/1.1_Binomial/1.1.1_Linear_binomial/27_1.1.1.7P[x#(' id='a'>+bx)^m(c+dx)^n(e+fx)^p/output/report.htm]<span class='ec-lmtt-12'>test_cases/rubi_
tests/1_Algebraic_functions/1.1_Binomial/1.1.1_Linear_
binomial/27_1.1.1.7P[x](a+bx)</span><sup><span class='cmr-8'>m</span></sup><span class='ec-lmtt-12'>(c+dx)</span><sup><span class='cmr-8'>n</span></sup><span class='ec-lmtt-12'>(e+fx)</span><sup><span class='cmr-8'>p</span></sup></a>     [100]
</li>
<li class='enumerate' id='x1-1004x2'>         <a href='test_cases/rubi_tests/1_Algebraic_functions/1.1_Binomial/1.1.1_Linear_binomial/28_1.1.1.8P[x#(' id='a'>+bx)^m(c+dx)^n(e+fx)^p(g+hx)^q/output/report.htm]<span class='ec-lmtt-12'>test_
cases/rubi_tests/1_Algebraic_functions/1.1_Binomial/1.1.1_
Linear_binomial/28_1.1.1.8P[x](a+bx)</span><sup><span class='cmr-8'>m</span></sup><span class='ec-lmtt-12'>(c+dx)</span><sup><span class='cmr-8'>n</span></sup><span class='ec-lmtt-12'>(e+fx)</span><sup><span class='cmr-8'>p</span></sup><span class='ec-lmtt-12'>(g+hx)</span><sup><span class='cmr-8'>q</span></sup></a>
[43]</li></ol>
 
</body> 
</html>

ps. I fixed the above by changing p[x] to p(x) in the folder name. It seems tex4ht got confused by [] in name.

May be I need to look at new way to do this. The problem is that the names of the file/path used can contain different strange characters and I do not want to change the names displayed to something else as the names are important.

Track reference is here

2
  • Your claim that you "use` \urldef` in order to make href, because the names are folder/file path which can contain many different strange characters" does not appear to be valid per se. AFAICT, the main instance of when using \urldef is indicated is when an \url or \href command features in the argument of a \footnote directive.
    – Mico
    Jan 16 at 1:26
  • 2
    do not mix problems. The first is an unwanted space in the text, the second a broken link because of the brackets in the path. And you already know that you can report this to the mailing list. Jan 16 at 10:21

1 Answer 1

2

The first issue is caused by the line break. You still have pages in TeX4ht, so if you have a long link, it will be broken over lines. You can fix that with this config file:

\Preamble{xhtml}

\textwidth=100cm
\begin{document}
\EndPreamble

The second issue is a bug in TeX4ht, it doesn't support ] character in the \href URL, because it uses this character as a macro delimiter internally. This version of hyperref.4ht should fix it:

% hyperref.4ht (2023-10-16-13:09), generated from tex4ht-4ht.tex
% Copyright 1999-2009 Eitan M. Gurari
% Copyright 2009-2023 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2023-10-16-13:09}

\csname end:hyperref\endcsname

\expandafter\ifx \csname ifHy@texht\endcsname\relax
   \expand:after{\expandafter
      \let \csname ifHy@texht\endcsname}\csname ifhy@texht\endcsname
\fi
\expandafter\ifx \csname ifHy@texht\endcsname\relax
   \expand:after{\expandafter
      \let \csname ifHy@texht\endcsname}\csname iffalse\endcsname
\fi
\ifHy@texht \else
    \:warning{tex4ht loaded after hyperref}
    \csname Hy@texhttrue\endcsname
\fi

\def\auto@setref#1#2#3{\@safe@activestrue
   \let\:autoref\::autoref
\T@ref{#3}\@safe@activesfalse}
\ifx\@refstar\:UnDef
  \def\@refstar{\let\:autoref\:gobble
\T@ref}
\fi
\def\:temp{\protect \T@ref}
\ifx \::ref\:temp
   \edef\::ref{\noexpand\protect \expandafter\noexpand \csname ::ref \endcsname}
   \expandafter\def\csname ::ref \endcsname{\@ifstar \@refstar \T@ref}
\fi
\def\:temp#1{\@safe@activestrue\org@:ref{#1}\@safe@activesfalse}
\expandafter\ifx \csname :ref \endcsname\:temp
   \expandafter\def\csname :ref \endcsname{\@ifnextchar*{\:refstar}{\r:ref}}
   \def\r:ref#1{\@safe@activestrue\org@:ref{#1}\@safe@activesfalse}
   \def\:refstar#1{\r:ref}
\fi

\expandafter\ifx \csname real@setref\endcsname\relax
   \def\@pagerefstar#1{%
      \HyRef@StarSetRef{#1}\@secondoffive
   }
   \def\@namerefstar#1{%
       \HyRef@StarSetRef{#1}\@thirdoffive
     }
   \def\HyRef@StarSetRef#1{%
     \begingroup
       \Hy@safe@activestrue
       \edef\x{#1}%
       \@onelevel@sanitize\x
       \edef\x{\endgroup
         \noexpand\HyRef@@StarSetRef
           \expandafter\noexpand\csname r@\x\endcsname{\x}%
       }%
     \x
   }

   \def\HyRef@@StarSetRef#1#2#3{%
     \ifx#1\@undefined
       \let#1\relax
     \fi
     \real@setref#1#3{#2}%
   }
\fi
\expandafter\ifx \csname real@setref\endcsname\relax
   \let\real@setref\@setref
\fi



\DeclareRobustCommand*{\autoref}{%
  \@ifstar{\HyRef@autoref\@gobbletwo}{\HyRef@autoref\hyper@@link}%
}
\def\HyRef@autoref#1#2{%
  \begingroup
    \Hy@safe@activestrue
    \expandafter\HyRef@autosetref\csname r@#2\endcsname{#2}{#1}%
  \endgroup
}

\DeclareRobustCommand*{\autopageref}{%
  \@ifstar{%
    \HyRef@autopagerefname\pageref*%
  }\HyRef@autopageref
}
\def\HyRef@autopageref#1{%
  \hyperref[{#1}]{\HyRef@autopagerefname\pageref*{#1}}%
}
\def\HyRef@autopagerefname{%
  \@ifundefined{pageautorefname}{%
    \@ifundefined{pagename}{%
      \Hy@Warning{No autoref name for `page'}%
    }{%
      \pagename\nobreakspace
    }%
  }{%
    \pageautorefname\nobreakspace
  }%
}

\def\HyRef@autosetref#1#2#3{% link command, csname, refname
  \HyRef@ShowKeysRef{#2}%
  \ifcase 0\ifx#1\relax 1\fi\ifx#1\Hy@varioref@undefined 1\fi\relax
    \edef\HyRef@thisref{%
      \expandafter\@fourthoffive#1\@empty\@empty\@empty
    }%
    \expandafter\HyRef@testreftype\HyRef@thisref.\\%
    \Hy@safe@activesfalse
    #3{%
      \expandafter\@fifthoffive#1\@empty\@empty\@empty
    }{%
      \expandafter\@fourthoffive#1\@empty\@empty\@empty
    }{%
      \HyRef@currentHtag
      \expandafter\@firstoffive#1\@empty\@empty\@empty
      \null
    }%
  \else
    \protect\G@refundefinedtrue
    \nfss@text{\reset@font\bfseries ??}%
    \@latex@warning{%
      Reference `#2' on page \thepage\space undefined%
    }%
  \fi
}

\def\HyRef@testreftype#1.#2\\{%
  \@ifundefined{#1autorefname}{%
    \@ifundefined{#1name}{%
      \HyRef@StripStar#1\\*\\\@nil{#1}%
      \@ifundefined{\HyRef@name autorefname}{%
        \@ifundefined{\HyRef@name name}{%
          \def\HyRef@currentHtag{}%
          \Hy@Warning{No autoref name for `#1'}%
        }{%
          \edef\HyRef@currentHtag{%
            \expandafter\noexpand\csname\HyRef@name name\endcsname
            \noexpand~%
          }%
        }%
      }{%
        \edef\HyRef@currentHtag{%
          \expandafter\noexpand\csname\HyRef@name autorefname\endcsname
          \noexpand~%
        }%
      }%
    }{%
      \edef\HyRef@currentHtag{%
        \expandafter\noexpand\csname#1name\endcsname
        \noexpand~%
      }%
    }%
  }{%
    \edef\HyRef@currentHtag{%
      \expandafter\noexpand\csname#1autorefname\endcsname
      \noexpand~%
    }%
  }%
}

\def\HyRef@StripStar#1*\\#2\@nil#3{%
  \def\HyRef@name{#2}%
  \ifx\HyRef@name\HyRef@CaseStar
    \def\HyRef@name{#1}%
  \else
    \def\HyRef@name{#3}%
  \fi
}
\def\HyRef@CaseStar{*\\}
\def\HyRef@currentHtag{}
\let\HyRef@ShowKeysRef\@gobble
\providecommand*\AMSautorefname{\equationautorefname}
\providecommand*\Hfootnoteautorefname{\footnoteautorefname}
\providecommand*\Itemautorefname{\itemautorefname}
\providecommand*\itemautorefname{item}
\providecommand*\equationautorefname{Equation}
\providecommand*\footnoteautorefname{footnote}
\providecommand*\itemautorefname{item}
\providecommand*\figureautorefname{Figure}
\providecommand*\tableautorefname{Table}
\providecommand*\partautorefname{Part}
\providecommand*\appendixautorefname{Appendix}
\providecommand*\chapterautorefname{chapter}
\providecommand*\sectionautorefname{section}
\providecommand*\subsectionautorefname{subsection}
\providecommand*\subsubsectionautorefname{subsubsection}
\providecommand*\paragraphautorefname{paragraph}
\providecommand*\subparagraphautorefname{subparagraph}
\providecommand*\FancyVerbLineautorefname{line}
\providecommand*\theoremautorefname{Theorem}
\providecommand*\pageautorefname{page}

\expandafter\ifx \csname H@item\endcsname\relax
   \def\:temp{dvi}\ifx \XR@ext\:temp \else
     \def\:temp{html}\ifx \XR@ext\:temp \else
         \:warning{\string\usepackage[...]{hyperref} assumes `\XR@ext'
              option, not `tex4ht'}
   \fi\fi
\else
      \:warning{\string\usepackage[...]{hyperref} assumes `\XR@ext'
           option, not `tex4ht'}
\fi

\ifx \@@wrindex\:UnDef \else
   \def\@@wrindex#1|#2|#3\\{%
     \protected@write\@indexfile{}{\string\indexentry{#1}{\thepage}}%
     \endgroup \@esphack
   }
\fi
\ifx \HyInd@@wrindex\:UnDef \else
   \def\HyInd@@wrindex#1#2|#3|#4\\{\HyInd@org@wrindex{#1}{#2}}%
\fi
\ifx \Hy@RestoreLastskip\:UnDef
   \let\Hy@RestoreLastskip\relax
\fi
\def\hyperlink#1#2{\Link{#1}{}#2\EndLink}
\def\hypertarget#1#2{\Link{}{#1}\EndLink#2}
\ifx \hyperpage\:UnDef  \let\hyperpage=\empty  \fi
\def\:temp#12->#2//{\def\:temp{#2}}
\expandafter\:temp\meaning\setkeys2->//
\ifx\:temp\empty \else
   \pend:defII\setkeys{%
      \expandafter\ifx \csname ##1:keys\endcsname\relax
             \expandafter\def\csname ##1:keys\endcsname{##2}%
      \else  \expandafter\append:def\csname ##1:keys\endcsname{##2}%
      \fi  }
\fi
\def\:choices#1,#2//#3#4{%
   \def\AttributeVal{#1}#3\AttributeVal#4%
   \def\:temp{#2}\ifx \:temp\empty \else
   \def\:temp{\:choices#2//{#3}{#4}}\expandafter\:temp\fi}
\def\check:args#1=#2//{\def\:temp{#2}}
\def\arg:quote#1=#2//{%
   \del:sp#1//%
   \expandafter\ifx \csname a:\:form:attr ::\nosp:arg\endcsname\relax
      \expandafter\ifx \csname a:::\nosp:arg\endcsname\relax
            \:warning{No configuration for \:form:attr ::\nosp:arg}%
      \else \def\AttributeVal{#2}\csname a:::\nosp:arg\endcsname
      \fi
   \else
      \def\AttributeVal{#2}\csname a:\:form:attr ::\nosp:arg\endcsname
   \fi
   }
\def\del:sp#1#2//{\def\nosp:arg{#1#2}}
\def\:form:attr{\ifx\:textarea\empty
   \default:textarea\else \:textarea\fi}
\def\scan:args#1{\let\Attributes=\empty \let\:textarea=\empty
   \expandafter\ifx \csname #1:keys\endcsname\relax
      \expandafter\scan:arg
   \else  \expand:after{\expand:after
      {\expandafter\scan:arg}\csname #1:keys\endcsname,}\fi
}
\def\scan:arg#1,#2//{%
   \def\:temp{#1}\ifx \:temp\empty\else \ifx \:temp\space\else
      \check:args#1=//%
      \ifx \:temp\empty
         \edef\:textarea{\ifx \:textarea\empty\else ,\fi #1}%
      \else
         \arg:quote#1//%
   \fi\fi\fi
   \def\:temp{#2}\ifx \:temp\empty \else
   \def\:temp{\scan:arg#2//}\expandafter\:temp\fi
}
\def\check:type#1{\:Optionfalse
   \def\:temp{#1}\expandafter\check:t\:textarea,//}%
\def\check:t#1,#2//{\def\:tempa{#1}\ifx \:temp\:tempa \:Optiontrue
   \else
       \def\:tempa{#2}\ifx\:tempa\empty\else \def\:tempa{\check:t#2//}\fi
       \expandafter\:tempa
   \fi}

\def\Hy@MakeCurrentHref#1{%
  \edef\HyperLocalCurrentHref{#1}%
  \@onelevel@sanitize\HyperLocalCurrentHref
  \global\let\HyperGlobalCurrentHref\HyperLocalCurrentHref
  \let\HyperLocalCurrentHref\HyperGlobalCurrentHref
  \ifHy@localanchorname
    \let\@currentHref\HyperLocalCurrentHref
  \else
    \global\let\@currentHref\HyperGlobalCurrentHref
  \fi
}

\let\Hy@SectionAnchorHref\@gobble
\newlength\Hy@SectionHShift

\def\Hy@MakeCurrentHrefAuto#1{%
  \Hy@GlobalStepCount\Hy@linkcounter
  \Hy@MakeCurrentHref{#1.\the\Hy@linkcounter}%
}

\@ifpackageloaded{nameref}{}
{%
   \let\sv:label\label
   \RequirePackage{nameref}%
   \let\label\sv:label
}
\def\hyper@makecurrent#1{%
  \begingroup
    \edef\Hy@param{#1}%
    \ifx\Hy@param\Hy@chapterstring
      \let\Hy@param\Hy@chapapp
    \fi
    \ifHy@hypertexnames
      \let\@number\@firstofone
      \@ifundefined{latin@Alph}{}{%
        \ifx\@Alph\greek@Alph
          \def\@Alph{Alph\@arabic}%
        \fi
      }%
      \ifHy@naturalnames
        \let\textlatin\@firstofone
        \xdef\@currentHlabel{\csname the#1\endcsname}%
      \else
        \xdef\@currentHlabel{\csname theH#1\endcsname}%
      \fi
      \xdef\@currentHref{%
        \Hy@param.\expandafter\strip@prefix\meaning\@currentHlabel
      }%
    \else
      \Hy@GlobalStepCount\Hy@linkcounter
      \xdef\@currentHref{\Hy@param.\the\Hy@linkcounter}%
    \fi
  \endgroup
}
\def\hyper@natlinkend{%
  \hyper@linkend
}
\def\hyper@linkurl#1#2{%
  \leavevmode  \begingroup    \hyper@chars
   \ifx \hyper:normalise\:UnDef
      \expandafter\pend:defI\expandafter\:autoref
                            \expandafter{\HyRef@currentHtag}%
      \let\HyRef@currentHtag\empty
      \Hy@colorlink{\@urlcolor}#1\Hy@endcolorlink
    \else
 \typeout{******************* jsem tuu \detokenize{#1, #2}}
      %\Link[#2]{}{}\Hy@colorlink{\@urlcolor}#1\Hy@endcolorlink\EndLink
      \def\:currentlink{#2}
      \Link[\noexpand\:currentlink]{}{}\Hy@colorlink{\@urlcolor}#1\Hy@endcolorlink\EndLink
      \global\let\hyper:normalise\:UnDef
    \fi
  \endgroup }
\AtBeginDocument{%
%  \pend:defI\hyper@normalise{\let\hyper:normalise\def}%
  \expandafter\pend:def\csname hyperref
                     \endcsname{\let\hyper:normalise\def}%
  \expandafter\pend:def\csname href \endcsname{\let\hyper:normalise\def}%
  \pend:defI\T@ref{\edef\RefArg{##1}}}
\def\label@@hyperref#1#2#3{%
  \ifx#1\relax
    \protect\G@refundefinedtrue
    \@latex@warning{%
      Hyper reference `#2' on page \thepage \space undefined%
    }%
    \begingroup
      \hyperrefundefinedlink{#3}%
    \endgroup
  \else%
    \def\hyperrefLabel{#3}%
    \Configure{ref}%
      {\Link}{\EndLink}{\Configure{ref}{}{}{}#3}\ref{#2}%
  \fi
}

\Configure{@newlabel}{\@onelevel@sanitize\@currentlabelname}
\append:def\protect:wrtoc{\def\ref{\protect\o:ref}}

\ifx \H@equation\:UnDef \else
   \let\o:equation:\H@equation
\fi
\ifx \H@endequation\:UnDef \else
   \let\o:endequation:\H@endequation
\fi
\ifx \H@eqnarray\:UnDef \else
   \let\o:eqnarray:\H@eqnarray
\fi
\ifx \H@endsubeqnarray\:UnDef \else
   \let\o:endsubeqnarray:\H@endsubeqnarray
\fi
\ifx \H@subeqnarray\:UnDef \else
   \let\o:subeqnarray:\H@subeqnarray
\fi
\ifx \H@endsubeqnarray\:UnDef \else
   \let\o:endsubeqnarray:\H@endsubeqnarray
\fi


\csname ReadBookmarks\endcsname
\ifx \Hy@linkfileprefix\empty\else
   \:warning{\noexpand\href of hyperref.sty introduces the prefix
             `\Hy@linkfileprefix' to prefix-free references.
             The command \string\hyperlinkfileprefix{...}
             may be used for changing the prefix (probably
             \string\hyperlinkfileprefix{}).}
\fi
\def\hyper@linkfile#1#2#3{\Link[#2]{#3}{}#1\EndLink}
\def\phantomsection{%
 \Hy@GlobalStepCount\Hy@linkcounter
 \xdef\@currentHref{likesection.\the\Hy@linkcounter}%
 \Hy@raisedlink{\hyper@anchorstart{\@currentHref}\hyper@anchorend}%
 \edef\@currentlabel{\the\Hy@linkcounter}%
 \AnchorLabel%
}
\catcode`\:=12
\def\@hyper@readexternallink#1#2#3#4:#5:#6\\#7{%
      \hyper@linkurl{#3}{#7\ifx\\#2\\\else\##2\fi}}
\catcode`\:=11
\def\T@pageref#1{%
  \Hy@safe@activestrue%
  \expandafter\@setref\csname r@#1\endcsname\@secondoffive{#1}%
  \Hy@safe@activesfalse%
}%
\def\T@Ref#1{%
  \Hy@safe@activestrue%
  \let\olda:rEfLiNK\rEfLiNK%%
  \def\rEfLiNK##1##2{\Link{##1}{}\edef\:ref:currentlabel{##2}\expandafter\MakeUppercase\:ref:currentlabel\EndLink}%
  \expandafter\@setref\csname r@#1\endcsname\@firstoffive{#1}%
  \let\rEfLiNK\olda:rEfLiNK%
  \Hy@safe@activesfalse%
}%
\def\@Refstar#1{%
  \Hy@safe@activestrue
  \let\olda:rEfLiNK\rEfLiNK%%
  \def\rEfLiNK##1##2{\Link{##1}{}\edef\:ref:currentlabel{##2}\expandafter\MakeUppercase\:ref:currentlabel\EndLink}%
  \expandafter\@setref\csname r@#1\endcsname\@firstoffive{#1}%
  \let\rEfLiNK\olda:rEfLiNK%
  \Hy@safe@activesfalse
}%

\def\Hy@PageAnchorSlidesPlain{}%
\def\Hy@PageAnchorSlide{}%
\def\@Form[#1]{%
   \def\default:textarea{Form}%
   \scan:args{}#1,//\a:Form }
                                        \def\@endForm{\b:Form}
                                         \NewConfigure{Form}{2}
\def\@TextField[#1]#2{%
   \def\default:textarea{TextField}%
   \scan:args{Field}#1,//%
   \csname a:TextField::\:textarea\endcsname  \leavevmode#2%
   \csname b:TextField::\:textarea\endcsname  }
\def\@PushButton[#1]#2{%
   \def\default:textarea{PushButton}%
   \scan:args{}#1,value=#2,//%
   \csname a:PushButton::\:textarea\endcsname }
\def\@Reset[#1]#2{%
   \def\default:textarea{Reset}%
   \scan:args{}#1,value=#2,//%
   \csname a:Reset::\:textarea\endcsname }
\def\@Submit[#1]#2{%
   \def\default:textarea{Submit}%
   \scan:args{}#1,value=#2,//%
   \csname a:Submit::\:textarea\endcsname }
\def\@CheckBox[#1]#2{%
   \def\default:textarea{CheckBox}%
   \scan:args{}#1,//%
   \csname a:CheckBox::\:textarea\endcsname
   #2\csname b:CheckBox::\:textarea\endcsname}
\def\@ChoiceMenu[#1]#2#3{%
   \def\default:textarea{ChoiceMenu}%
   \scan:args{}#1,//%
   \csname a:ChoiceMenu::\:textarea\endcsname  \leavevmode#2%
   \csname b:ChoiceMenu::\:textarea\endcsname
   \:choices  #3,//{\csname d:ChoiceMenu::\:textarea\endcsname}%
         {\csname e:ChoiceMenu::\:textarea\endcsname}%
   \csname c:ChoiceMenu::\:textarea\endcsname }

\def\hyper@linkstart#1#2{%
  \expandafter\Hy@colorlink\expandafter{\csname @#1color\endcsname}%
  \def\Hy@tempa{#1}%
  \ifx\Hy@tempa\@urltype
    \Link[#2]{}{}%
  \else
    {\hyper@chars\ifx\rel:hyper\def\Link{#2}{}\else\Link[\##2]{}{}\fi}%
  \fi  \global\let\rel:hyper=\:UnDef
}
\def\hyper@linkend{%
  \EndLink
  \Hy@endcolorlink
}
\def\hyper@anchorstart#1{%
  \Hy@SaveLastskip
  \begingroup
    \hyper@chars\Link{}{#1}%
  \endgroup
  \Hy@activeanchortrue
}
\def\hyper@anchorend{%
  \EndLink
  \Hy@activeanchorfalse
  \Hy@RestoreLastskip
}
\def\hyper@anchor#1{\hyper@anchorstart{#1}\hyper@anchorend}

\expandafter\ifx\csname ifHy@hyperindex\endcsname\relax
\else \Hy@hyperindexfalse
\fi
\Hinput{hyperref}
\endinput

This is the result for the spacing MWE:

enter image description here

And this is the result for brackets example:

enter image description here

You must log in to answer this question.

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