Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I noticed I am getting a new char displayed on the HTML page which did not exist when I was using TL 2012 with htlatex. I narrowed it down to including \usepackage{hyperref} This extra "]" shows only in the HTML, not in the PDF

\documentclass[12pt]{article}%
\begin{document}
text
\section{example using Table[Plot...]}
text
\end{document}

gives expected output

enter image description here

Now adding \usepackage{hyperref} gives this:

\documentclass[12pt]{article}%
\usepackage{hyperref}
\begin{document}
text
\section{example using Table[Plot...]}
text
\end{document}

enter image description here

Notice the extra "]" there.

Command used and part of the display on the screen:

>htlatex foo5.tex
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2011/06/27>

(/usr/local/texlive/2013/texmf-dist/tex/latex/oberdiek/auxhook.sty

Package auxhook Warning: Cannot patch \document,
(auxhook)                using \AtBeginDocument instead.

) (/usr/local/texlive/2013/texmf-dist/tex/latex/oberdiek/kvoptions.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/local/texlive/2013/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/usr/local/texlive/2013/texmf-dist/tex/latex/url/url.sty)

Package hyperref Message: Stopped early.

)

Package hyperref Message: Driver: htex4ht.

[1 file foo5.html
 file foo5.css
 file foo5.tmp
]
Execute script `foo5.lg'
----------------------------
t4ht.c (2012-07-25-19:28 kpathsea)
t4ht -f/foo5.tex 
(/usr/local/texlive/2013/texmf-dist/tex4ht/base/unix/tex4ht.env)
Entering foo5.lg
Entering foo5.css
Entering foo5.tmp
>

The HTML generated is

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  
  "http://www.w3.org/TR/html4/loose.dtd">  
<html > 
<head><title></title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)"> 
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)"> 
<!-- html --> 
<meta name="src" content="foo5.tex"> 
<meta name="date" content="2013-06-22 21:56:00"> 
<link rel="stylesheet" type="text/css" href="foo5.css"> 
</head><body 
>
<!--l. 4--><p class="noindent" >text
   <span 
class="cmbx-12x-x-144">]</span>
   <h3 class="sectionHead"><span class="titlemark">1   </span> <a 
 id="x1-10001"></a>example using Table[Plot...]</h3>
<!--l. 6--><p class="noindent" >text  
</body></html> 

New installation of TL2013, on Linux mint 15

>which htlatex
/usr/local/texlive/2013/bin/i386-linux/htlatex

>latex -v
pdfTeX 3.1415926-2.5-1.40.14 (TeX Live 2013)
kpathsea version 6.1.1
Copyright 2013 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.5.16; using libpng 1.5.16
Compiled with zlib 1.2.7; using zlib 1.2.7
Compiled with xpdf version 3.03
>

>tex4ht
----------------------------
tex4ht.c (2012-07-25-19:36 kpathsea)
share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

It is a bug in nameref.4ht, the support file of tex4ht for package nameref:

\def\no@sect#1#2#3#4#5#6[#7]#8{\gdef\NR:Title{\a:newlabel{#7}}%
    \gdef\NR:Type{#1}%
    \NR:no@sect{#1}{#2}{#3}{#4}{#5}{#6}[#7]{#8}}
\def\:tempc#1#2#3#4#5#6[#7]#8{%
   \gdef\NR:Title{\a:newlabel{#7}}%
   \gdef\NR:Type{#1}%
   \o:NR@sect:{#1}{#2}{#3}{#4}{#5}{#6}[#7]{#8}}
\HLet\NR@sect\:tempc

Argument #7 contains the title string with example using Table[Plot...], calling it as optional argument becomes:

\...{<#1>}...{<#6>}[example using Table[Plot...]]{<#8>}

That means, already the first closing bracket ] matches and closes the optional argument. The second ] becomes the next argument instead of {<#8>}.

Patch:

The trick is to use curly braces: [{#7}] instead of [#7]. Then this is robust, if #7 contains square brackets:

\documentclass[12pt]{article}%
\usepackage{hyperref}

\makeatletter
\catcode`\:=11 %
\AtBeginDocument{%
  \@ifpackageloaded{tex4ht}{%
    \def\no@sect#1#2#3#4#5#6[#7]#8{\gdef\NR:Title{\a:newlabel{#7}}%
        \gdef\NR:Type{#1}%
        \NR:no@sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]{#8}%
    }
    \def\:tempc#1#2#3#4#5#6[#7]#8{%
       \gdef\NR:Title{\a:newlabel{#7}}%
       \gdef\NR:Type{#1}%
       \o:NR@sect:{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]{#8}}
    \HLet\NR@sect\:tempc
  }{}%
}%
\@makeother\:
\makeatother

\begin{document}
text
\section{example using Table[Plot...]}
text
\end{document}

Update:

Thanks to the bug report #185 of michael.h21 (see his comment), CV Radhakrishnan has updated nameref.ht4 in the source repository with date 2013-06-28. This update fixes the problem.

share|improve this answer
    
Thanks. But now pdflatex does not compile. ! Undefined control sequence. \@begindocumenthook ...5}{##6}[{##7}]{##8}} \HLet \NR@sect \:tempc \ifx \hyp... l.4 \begin{document} What should I do? thanks. ? –  Nasser Jun 23 '13 at 3:54
    
I've added logic around your patch, so that it is only seen when htlatex is running, using \if\texforht ... patch .... \fi, now document works with both pdflatex and with htlatex no problem. thanks. –  Nasser Jun 23 '13 at 4:05
    
@Nasser: Thanks, I have added a test for package tex4ht in the patch. Otherwise \HLet would be undefined without tex4ht. –  Heiko Oberdiek Jun 23 '13 at 9:37
    
I posted this issue with patch based on your code to tex4ht bug repository - puszcza.gnu.org.ua/bugs/index.php?185 –  michal.h21 Jun 23 '13 at 11:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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