Open ThiloteE opened 2 years ago
This is really nice issue. The problem is that BibLaTeX points back references back to the pages where they appeared. This cannot work in HTML, as there are no physical pages. So instead, we will insert link destination to first citation on the page (TeX4ht still knows page numbers in the compilation, even though there are no pages in HTML), and backlinks will link to these citations.
I've made similar solution for the issue you linked, so here is a version that reuses that code for BibLaTeX. The following biblatex.4ht
file should work for your file:
% biblatex.4ht (2021-12-20-08:56), generated from tex4ht-4ht.tex
% Copyright 2007-2009 Eitan M. Gurari
% Copyright 2009-2021 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 2021-12-20-08:56}
\def\make:blx:ver#1.#2#3\relax{%
%\ifdim#1pt< 3pt \xdef\blx:ver:no{2}\else\xdef\blx:ver:no{3}\fi%
\gdef\blx:ver:no{#1}
\gdef\blx:subver:no{#2}
}
\expandafter\make:blx:ver\abx@version.0\relax
\ifx\a:printshorthands\Undef\let\blx@shorthands\@empty\fi
\ifx\blx@startbib\:UnDef
\pend:def\blx@shorthands{%
\pend:def\blx@bibinit{%
\HAssign\shorthands:cnt=0
\NewConfigure{printfield-shorthand}{2}%
\Configure{printfield-shorthand}%
{\gHAdvance\shorthands:cnt by 1\relax
\ifnum \shorthands:cnt=1 \a:printshorthands
\else \c:printshorthands \fi
}
{\d:printshorthands}%
\append:def\endtheshorthands{\b:printshorthands}%
\csname a:@shorthands\endcsname}
}
\ifx\b:printshorthands\Undef\let\endtheshorthands\@empty\fi
\def\a:entryhead{CVR}
\def\a:entryhead:full{CV Radhakrishnan}
\ifx\bib@macro@entryhead:name\UnDef
\let\bib@macro@entryhead:name\@empty\fi
\ifx\bib@macro@entryhead:full\UnDef
\let\bib@macro@entryhead:full\@empty\fi
\gdef\BibFileName[#1]#2{\expandafter\xdef\csname
BibFileName#1\endcsname{#2}}
\newcount\sv:sec:cnt
\def\bibSecConfigure{%
\let\save:section\section
\global\sv:sec:cnt=\c@secnumdepth
\def\section{\@ifstar
{\c@secnumdepth=0\relax\save:section}%
{\c@secnumdepth=\sv:sec:cnt\save:section}}%
}
\gHAssign\bibN=0
\ifdefined\TE@hook\else%
\def\TE@hook{}%
\fi%
\AtBeginDocument{%
\Configure{ifthenelse}{\TE@hook}
}
\:CheckOption{ooffice}\if:Option
\def\bibConfigure{\ConfigureList{thebibliography}%
{\IgnorePar\EndP \gHAdvance\bib:N by 1
\HCode{<text:bibliography text:name="bib-\bib:N" >
<text:bibliography-source>\Hnewline
<text:index-title-template>}
\NoFonts\ref:name\EndNoFonts
\HCode{</text:index-title-template>\Hnewline
%
<text:bibliography-entry-template\Hnewline
text:bibliography-type="custom1"
text:style-name="Bibliography11">\Hnewline
%
<text:index-entry-bibliography
text:bibliography-data-field="identifier"/>\Hnewline
%
<text:index-entry-span>: </text:index-entry-span>\Hnewline
<text:index-entry-bibliography
text:bibliography-data-field="author" />\Hnewline
<text:index-entry-span>, </text:index-entry-span>\Hnewline
%
<text:index-entry-bibliography
text:bibliography-data-field="title" />\Hnewline
<text:index-entry-span>, </text:index-entry-span>\Hnewline
%
<text:index-entry-bibliography
text:bibliography-data-field="year" />\Hnewline
</text:bibliography-entry-template>\Hnewline\Hnewline
</text:bibliography-source>\Hnewline
<text:index-body>\Hnewline}%
\let\en:bib=\empty
}%
{\en:bib\HCode{</text:index-body></text:bibliography>}}
{\en:bib\gdef\en:bib{\HCode{</text:p>\Hnewline}}%
\HCode{<text:p text:style-name="p-bibitem">}%
\gHAdvance\bibN by 1
\HCode{<text:reference-mark
text:name="X0-\csname BIB-\bibN\endcsname">%
</text:reference-mark>}%
}%
{}{}
}
\else
\def\bibConfigure{%
\ConfigureList{thebibliography}
{\ifvmode \IgnorePar \fi \EndP \EndP
\HCode {<dl class="thebibliography">}%
%
% This is for linking citations with biblist items which
% are in a different file when output is split into different
% chunks. [CVR 2012-09-27]
%
%
% <biblatex-2.2>
%
\immediate\write\@auxout{%
\string\BibFileName[\therefsection]{\FileName}}%
%
% </biblatex-2.2>
%
\PushMacro \end:itm \global \let \end:itm =\empty}%
{\ifvmode \IgnorePar \fi \EndP
\PopMacro \end:itm \global \let \end:itm \end:itm \EndP
\HCode {</dd></dl>}\ShowPar}%
{\ifvmode \IgnorePar \fi \EndP \gHAdvance \bibN by 1
\end:itm \global \def \end:itm {\EndP \Tg </dd>}%
\HCode {<dt id="X\therefsection-\abx@field@entrykey"
class="thebibliography">}\bgroup \bf}%
{\ifvmode \IgnorePar \fi \EndP
\egroup
\HCode {</dt><dd\Hnewline id="bib-\bibN"
class="thebibliography">}%
\par \ShowPar}%
}
\fi
\NewConfigure{printshorthands}{4}
\NewConfigure{@shorthands}[1]{\concat:config\a:@shorthands{#1}}
\let\a:@shorthands\empty
% \def\nolinkurl{\o:url:}
% \def\blx@checksum{\ifx \blx@checksum@old \blx@checksum@new \else
% \blx@warning@noline {Page references have changed.\MessageBreak
% Rerun to get references right}\@tempswatrue \blx@reruntrue \fi
% \@nameuse {blx@rerun}}
\def\blx@checksum#1#2#3{%
\begingroup
\blx@tempcnta\the\numexpr0#2*0#3\relax
\blx@tempcntb\blx@tempcnta
\divide\blx@tempcntb10
\multiply\blx@tempcntb10
\advance\blx@tempcnta-\blx@tempcntb
\xdef#1{#1\the\blx@tempcnta}%
\endgroup}
\@ifpackagelater{biblatex}{2018/03/01}{\let\blx:pend:def\pend:defI}{\let\blx:pend:def\pend:def}
\blx:pend:def\blx@bibliography{\bibSecConfigure%
\pend:def\blx@bibinit{%
\bibConfigure
\csname onthebibliography:list\endcsname
}%
}
\let\en:bib\@empty
\newcounter{bib}
\ifnum\blx:ver:no < 3
\protected\def\blx@bbl@entry#1#2#3{%
\begingroup
\def\texht@bibkey{#1}
\edef\abx@field@entrykey{\detokenize{#1}}%
\global\advance\c@bib 1
\immediate\write\@auxout{\string\expandafter\string\gdef
\string\csname\space BIB-\thebib\string\endcsname
{\expandafter\strip@prefix\meaning\texht@bibkey}}%
\Tag{)QX\therefsection-#1}{\thebib}%
\blx@setoptions@type{#2}%
\blx@bbl@options{#3}%
\blx@setoptions@entry
\edef\blx@bbl@data{blx@data@\the\c@refsection @\abx@field@entrykey}%
\csuse\blx@bbl@data
\cslet\blx@bbl@data\@empty
\blx@bbl@addfield{entrykey}{\abx@field@entrykey}%
\blx@bbl@addfield{entrytype}{#2}%
\blx@imc@iffieldundef{options}
{}
{\blx@bbl@fieldedef{options}{\expandonce\abx@field@options}}}
%
\protected\def\blx@finentry{%
\unspace
\a:finentry
\finentrypunct
\blx@postpunct
\b:finentry
\blx@initunit
}
%
\else
% Biblatex 3.0
%
% Hacks for biblatex
% MakeUppercase is redefined by tex4ht, biblatex tries to redefine it as well, but it relies on original
% LaTeX version:
\DeclareRobustCommand{\MakeUppercase}[1]{{%
\def\i{I}\def\j{J}%
\def\reserved@a##1##2{\let##1##2\reserved@a}%
\expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
\let\UTF@two@octets@noexpand\@empty
\let\UTF@three@octets@noexpand\@empty
\let\UTF@four@octets@noexpand\@empty
\blx@hook@uc\protected@edef\reserved@a{\uppercase{#1}}%
\reserved@a
}}
% Same applies also for \MakeLowercase
\DeclareRobustCommand{\MakeLowercase}[1]{{%
\def\reserved@a##1##2{\let##2##1\reserved@a}%
\expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
\let\UTF@two@octets@noexpand\@empty
\let\UTF@three@octets@noexpand\@empty
\let\UTF@four@octets@noexpand\@empty
\blx@hook@lc\protected@edef\reserved@a{\lowercase{#1}}%
\reserved@a
}}
% I don't really understand this, but language processing is broken by default
% with biblatex. It loads language file, but it executes code which should be
% executed only in the case if the language file fails, it displays an error message
% and language handling doesn't work. When we execute following code, the language
% files are loaded before checking of the success and it seems to work.
\AtBeginDocument{%
\@ifpackageloaded{babel}
{% This is required for languages which are never explicitly selected
% It seems this code was executed also with Polyglossia, where it caused compilation error
\@ifpackageloaded{polyglossia}{}{%
\def\do#1{\blx@lbxinput{#1}{}{}}%
\ifx\@empty\bbl@loaded\else%
\expandafter\docsvlist\expandafter{\bbl@loaded}%
\fi}}{}%
}
\fi % end of version boolean
\NewConfigure{finentry}{2}
\def\:tempc[#1]#2{%
\expandafter\ifx \csname a:printfield-#2\endcsname\relax
\NewConfigure{printfield-#2}{2}%
\a:printfield{printfield-#2}%
\fi
\Configure{blx@unit}%
{\csname a:printfield-#2\endcsname}%
{\csname b:printfield-#2\endcsname}%
\csname o:\string\blx@printfield:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@printfield\endcsname\:tempc
\NewConfigure{printfield}[1]{\def\a:printfield##1{#1}}
\Configure{printfield}{%
\Configure{#1}%
{\HCode{<!--#1-->}}%
{\HCode{<!--/#1-->}}%
}
\def\:tempc[#1]#2{%
\expandafter\ifx \csname a:bibstring-#2\endcsname\relax
\NewConfigure{bibstring-#2}{2}%
\a:printfield{bibstring-#2}%
\fi
\Configure{blx@unit}%
{\csname a:bibstring-#2\endcsname}%
{\csname b:bibstring-#2\endcsname}%
\csname o:\string\blx@bibstring:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@bibstring\endcsname\:tempc
\def\:tempc[#1]#2{%
\expandafter\ifx \csname a:bibcpstring-#2\endcsname\relax
\NewConfigure{bibcpstring-#2}{2}%
\a:printfield{bibcpstring-#2}%
\fi
\Configure{blx@unit}%
{\csname a:bibcpstring-#2\endcsname}%
{\csname b:bibcpstring-#2\endcsname}%
\csname o:\string\blx@bibcpstring:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@bibcpstring\endcsname\:tempc
\def\:tempc[#1]#2{%
\expandafter\ifx \csname a:biblcstring-#2\endcsname\relax
\NewConfigure{biblcstring-#2}{2}%
\a:printfield{biblcstring-#2}%
\fi
\Configure{blx@unit}%
{\csname a:biblcstring-#2\endcsname}%
{\csname b:biblcstring-#2\endcsname}%
\csname o:\string\blx@biblcstring:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@biblcstring\endcsname\:tempc
\def\:tempc[#1]#2{%
\expandafter\ifx \csname a:bibucstring-#2\endcsname\relax
\NewConfigure{bibucstring-#2}{2}%
\a:printfield{bibucstring-#2}%
\fi
\Configure{blx@unit}%
{\csname a:bibucstring-#2\endcsname}%
{\csname b:bibucstring-#2\endcsname}%
\csname o:\string\blx@bibucstring:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@bibucstring\endcsname\:tempc
\NewConfigure{biblatex-style}[2]{%
\def\:temp{#1}%
\ifx \:temp\blx@cbxfile
#2%
\global\let\biblatex:style\def
\fi
}
\def\biblatex:style{}
\Configure{biblatex-style}{}{}
\pend:def\at:docend{%
\ifx \UnDef\biblatex:style
\:warning{\string\Configure{biblatex-style}{\blx@cbxfile}{...}
not available}%
\fi
}
\let\blx:item\@item
\def\@item[#1]{%
\blx:item[#1]%
\ifhmode \spacefactor\blx@sf@par\fi
}
\let\blx@resetpuncthook\@empty
\let\blx@csq@ifkernmark\@empty
\newskip\blx@unitmark
\blx@unitmark=10pt plus 1pt minus 1pt
\let\abx@aux@page\@gobbletwo
\let\abx@aux@fnpage\@gobbletwo
\let\abx@aux@refsection\@gobbletwo
%
% <Kristian.Debrabant@cs.kuleuven.be> reported that After updating
% biblatex and biblatex.ht to versions 2.2 respectively
% 2012-09-28-17:49 (using MiKTeX 2.9 64 bit), tex4ht seemed no longer
% respected the defernumbers option in biblatex.sty: When applied to
% the attached file tex4hterror.tex.
%
% The problem was due to nullifying \abx@aux@number which in fact
% should have been redefined to \blx@aux@number when defernumbers
% option is true.
%
% This is done now and as per Kristian, the fix works fine now.
%
\ifnum\blx:ver:no < 3
%
\protected\def\blx@aux@number#1#2#3#4{%
\blx@bbl@addentryfield{\detokenize{#2}}{#3}{localnumber}{#4}%
\ifblank{#4}%
{}%
{\csgdef{blx@labelnumber@#3}{#4}%
%\blx@addchecksum{#1}{#4} % this can cause a nodocument error!
}}
%
\iftoggle{blx@defernumbers}%
{\setkeys{blx@opt@pre}{labelnumber}%
\let\blx@thelabelnumber\blx@addlabelnumber
\let\abx@aux@number\blx@aux@number}%
{\let\blx@thelabelnumber\relax
\let\abx@aux@number\@gobblefour}
%
\else
\def\@gobblefive#1#2#3#4#5{}%
\protected\def\blx@aux@number#1#2#3#4#5{%
\blx@bbl@addentryfield{\detokenize{#2}}{#3}{localnumber}{#4}{#5}%
\blx@bbl@addentryfield{\detokenize{#2}}{#3}{labelnumber}{#4}{#5}%
\global\toggletrue{blx@localnumber}%
\ifblank{#5}
{}
{\csgdef{blx@labelnumber@#3@#4}{#5}}}
\iftoggle{blx@defernumbers}%
{\setkeys{blx@opt@pre}{labelnumber}%
\let\blx@thelabelnumber\blx@addlabelnumber
\let\abx@aux@number\blx@aux@number}%
{\let\blx@thelabelnumber\relax
\let\abx@aux@number\@gobblefive}
\fi % end of version boolean
%
\AtEndDocument{%
\def\abx@aux@page#1#2{\blx@addpagesum{#1}{#2}}%
\def\abx@aux@fnpage#1#2{\blx@addpagesum{#1}{#2}}%
}
%
\def\blx@begunit{%
\toggletrue{blx@tempa}%
\iftoggle{blx@insert}%
{\iftoggle{blx@unit}%
{\begingroup
\let\blx@begunit\@empty
\let\blx@endunit\@empty
\let\blx@endnounit\@empty
\blx@unitpunct\blx@postpunct
\endgroup
\global\togglefalse{blx@unit}%
\togglefalse{blx@tempa}}
{\blx@postpunct}%
\iftoggle{blx@block}%
{\begingroup
\let\blx@begunit\@empty
\let\blx@endunit\@empty
\let\blx@endnounit\@empty
\newblockpunct
\endgroup
\global\togglefalse{blx@block}%
\togglefalse{blx@tempa}}%
{}}%
{}%
\blx@postpunct
\blx@resetpuncthook
\iftoggle{blx@tempa}%
{}%
{\global\togglefalse{blx@insert}}%
\csname a:blx@unit\endcsname
\blx@leavevmode
\blx@csq@ifkernmark
{}%
{\penalty\@M
\hskip-\blx@unitmark\relax
\hskip\blx@unitmark\relax
}%
\begingroup
\Configure{blx@unit}{}{}%
}
\def\blx@endunit{%
\endgroup
\csname b:blx@unit\endcsname
\Configure{blx@unit}{}{}%
\ifdim\lastskip=\blx@unitmark
\unskip\unskip\unpenalty
\global\togglefalse{blx@lastins}%
\else
\global\toggletrue{blx@insert}%
\global\toggletrue{blx@lastins}%
\fi
}
\NewConfigure{blx@unit}{2}
%
\else
\fi
\ifdefined\XeTeXversion
\def\abx@aux@defaultrefcontext#1#2#3{%
\global\boolfalse{refcontextdefaults}%
\csxdef{blx@assignedrefcontextbib@#1@\detokenize{#2}}{\detokenize{#3}}}
\fi
\NewConfigure{thebibliography}{4}
\append:def\blx@bibinit{\a:bibinit}%
\NewConfigure{bibinit}{1}%
\let\blx@anchors\@empty
\let\bib@field@entrykey\@empty
\protected\def\blx@anchor{%
\xifinlist{X\the\c@refsection -%@
\bib@field@entrykey}{\blx@anchors}%
{}%
{\listxadd\blx@anchors{X\the\c@refsection -%@
\bib@field@entrykey}%
\hyper:natanchorstart{X\the\c@refsection -%@
\bib@field@entrykey}%
\hyper:natanchorend}}
\protected\def\blx@bibhyperref{%
\@ifnextchar[%]
{\blx@bibhyperref@i}%
{\blx@bibhyperref@i[\bib@field@entrykey]}}%
\long\def\blx@bibhyperref@i[#1]#2{%
\hyper:natlinkstart{X\the\c@refsection -%@
#1}%
#2\hyper:natlinkend}%
\protected\long\def\blx@bibhyperlink#1#2{%
\hyper:natlinkstart{X\the\c@refsection -%:
#1}%
#2\hyper:natlinkend}%
\protected\long\def\blx@bibhypertarget#1#2{%
\@bsphack
\hyper:natanchorstart{X\the\c@refsection -%:
#1}%
\@esphack
#2\hyper:natanchorend}%
\let\blx@ifhyperref\@firstoftwo
% Oleg Domanov odomanov@yandex.ru reports:
% tex4ht ends with an error when compiles biblatex files. I'm on
% Windows, texlive 2012. I put here a minimal example and files
% generated with the command latexmk test && mk4ht oolatex test
%
% https://www.dropbox.com/s/hn1zm40htqs13mf/t4htlink.zip
%
% There is a superfluous \relax in the file test.tmp, line 65 which
% seems to cause the error.
%
% Changes to cope with biblatex upgrade caused this problem. It is now
% fixed. --CVR 2012/10/26
%
\:CheckOption{ooffice}\if:Option
\def\hyper:natanchorstart#1{\Link{}{#1}\EndLink}%
\def\hyper:natlinkstart#1{\Link{#1}{}}%
\else
\def\hyper:natanchorstart#1{%
\expandafter\ifx\csname QXpage.\thepage\endcsname\relax%
\Tag{)Qpage.\thepage}{\file:id}%
\HCode{<a id="page.\thepage"></a>}%
\expandafter\xdef\csname QXpage.\thepage\endcsname{0}%
\fi
\Link[\csname BibFileName\therefsection\endcsname]{}{#1}\EndLink}
\def\hyper:natlinkstart#1{%
\expandafter\ifx\csname QXpage.\thepage\endcsname\relax%
\Tag{)Qpage.\thepage}{\file:id}%
\HCode{<a id="page.\thepage"></a>}%
\expandafter\xdef\csname QXpage.\thepage\endcsname{0}%
\fi
\Link[\csname BibFileName\therefsection\endcsname]{#1}{}}
\fi
\def\hyper:natanchorend{}
\def\hyper:natlinkend{\EndLink}
\def\writeCiteLink#1{\immediate\write\@mainaux{%
\string\@namedef{#1.\thepage}{\FileName}}}
\let\blx@addpagesum\@gobbletwo
% \let\nolinkurl\relax
\ifx\blx:ver:no < 3
%
% biblatex 2.9a
%
% Newly added to process {keylist} environment (CVR)
%
\let\keylist\description
\let\endkeylist\enddescription
\def\keyitem#1{\item[#1]}%
%
%
\else
%
% biblatex 3.0
%
\let\keylist\Un:def
\let\endkeylist\Un:def
\newenvironment*{keylist}
{\list{}{%
\setlength{\labelwidth}{1.25in}%
\setlength{\labelsep}{10pt}%
\setlength{\leftmargin}{0pt}%
\setlength{\itemsep}{0pt}%
\raggedright%
\renewcommand*{\makelabel}[1]{\hss\bfseries##1}}}
{\endlist}
%
\def\keyitem#1{%
\item[#1]
\begingroup
\keyitemhook%
\blx@bibinit%
\midsentence\ifbibstring{#1}{}{\latintext}\biblstring{#1}%
\expandafter\lbx@initnamehook\lsmartoftext%
\par\nobreak
\midsentence\ifbibstring{#1}{}{\latintext}\bibsstring{#1}%
\expandafter\lbx@initnamehook\ssmartoftext%
\endgroup
\par\nobreak}
\fi % End of version boolean
\ConfigureList{keylist}%
{\EndP\HCode{<dl \a:LRdir class="description">}%
\PushMacro\end:itm
\global\let\end:itm=\empty}%
{\PopMacro\end:itm \global\let\end:itm \end:itm
\EndP\HCode{</dd></dl>}\ShowPar}%
{\end:itm \global\def\end:itm{\EndP\Tg</dd>}\HCode{<dt
class="description">}\bgroup \bf}%
{\egroup\EndP\HCode{</dt><dd\Hnewline class="description">}}
\let\:temp\do
\def\do#1{%
\patchcmd#1%
{\color@begingroup}%
{\color@begingroup\toggletrue{blx@footnote}}%
{\togglefalse{blx@tempa}\listbreak}%
{}}%
\docsvlist{%
\@footnotetext,% latex
\H@@footnotetext,% hyperref
\scr@saved@footnotetext,% koma-script 3.x
\l@dold@footnotetext,% ledmac
\l@doldold@footnotetext,% ledmac
\@fntORI}% frenchle
\let\do\:temp
\pend:defI\blx@backref{%
% prevent duplicate backlink on the same page
\ifcsdef{bk##1\thepage}{}{%
% insert link to the page
\html:addr\Link-{}{x\last:haddr}\EndLink%
% save link to the .xref file
\Tag{)Q##1\thepage}{x\last:haddr}%
% we need to save the link destination in .xref file
% too, otherwise \Link command would issue warning
\Tag{)Qx\last:haddr}{\FileNumber}%
}%
% declare this backlink destination as used, so we don't
% declare another one with the same name
\expandafter\gdef\csname bk##1\thepage\endcsname{}%
}
\def\bbx:hyperlink#1#2{
% test if we saved link to the current bibitem and page
\ifTag{)Q\abx@field@entrykey#2}{%
\Link{\LikeRef{)Q\abx@field@entrykey#2}}{}#2\EndLink%
}%
{#2}% print just page number if there is no saved link
}
\DeclareListFormat{pageref}{%
% we redefine \hyperlink command to link page numbers in backreferences
% back to the citations on the given pages
\let\orig:hyperlink\hyperlink%
\let\hyperlink\bbx:hyperlink%
\ifnumless{\abx@pagerefstyle}{0}
{\usebibmacro{list:plain}%
\ifhyperref
{\hyperlink{page.#1}{#1}}
{#1}}
{\ifnumequal{\value{listcount}}{1}
{\usebibmacro{pageref:init}}
{}%
\usebibmacro{pageref:comp}{#1}%
\ifnumequal{\value{listcount}}{\value{liststop}}
{\usebibmacro{pageref:dump}}
{}}
\let\hyperlink\orig:hyperlink%
}
\Hinput{biblatex}
\endinput
Awesome! i will test it tomorrow.
Unfortunately, it did not compile. I got an error:
PS E:\server-t-150\FAU\4. Semester\IPOE Froehlich Non EU und Institutionen\00 Hausarbeit Fröhlich 4\00 Finales Dokument zur veröffentlichung\Für IAPSS\latex> make4ht --lua (2021-08-13)BitcoinCrisesMonetarism.tex "mathml"
[WARNING] mkparams: Cannot find input file: 2000
[STATUS] make4ht: Conversion started
[STATUS] make4ht: Input file: 2000
[WARNING] tocid: char-def module not found
[WARNING] tocid: cannot fix section id's
This is LuaTeX, Version 1.14.0 (MiKTeX 21.12 NEXT)
restricted system commands enabled.
[ERROR] htlatex: Compilation errors in the htlatex run
[ERROR] htlatex: Filename Line Message
[ERROR] htlatex: ? ? Emergency stop.
[ERROR] htlatex: ? ? ==> Fatal error occurred, bad output DVI file produced!
[FATAL] make4ht-lib: Fatal error. Command htlatex returned exit code 1
PS E:\server-t-150\FAU\4. Semester\IPOE Froehlich Non EU und Institutionen\00 Hausarbeit Fröhlich 4\00 Finales Dokument zur veröffentlichung\Für IAPSS\latex> make4ht (2021-08-13)BitcoinCrisesMonetarism.tex "mathml"
[WARNING] mkparams: Cannot find input file: 2000
[STATUS] make4ht: Conversion started
[STATUS] make4ht: Input file: 2000
[WARNING] tocid: char-def module not found
[WARNING] tocid: cannot fix section id's
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (MiKTeX 21.12 NEXT) (preloaded format=latex.fmt)
restricted \write18 enabled.
entering extended mode
[ERROR] htlatex: Compilation errors in the htlatex run
[ERROR] htlatex: Filename Line Message
[ERROR] htlatex: ? ? Emergency stop.
[FATAL] make4ht-lib: Fatal error. Command htlatex returned exit code 1
PS E:\server-t-150\FAU\4. Semester\IPOE Froehlich Non EU und Institutionen\00 Hausarbeit Fröhlich 4\00 Finales Dokument zur veröffentlichung\Für IAPSS\latex>
This here was in a log file called 2000.log:
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (MiKTeX 21.12 NEXT) (preloaded format=latex 2021.12.16) 21 DEC 2021 15:10
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx\HCode\def\HCod
e##1{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\A
ddToHook{class/before}{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyl
e\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endc
sname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\doc
umentstyle[tex4ht]}}}\makeatother\HCode xhtml,BitcoinCrisesMonetarism.tex,chars
et=utf-8,html5.a.b.c.\input \detokenize{2000} > nul 2>&1
! Emergency stop.
<*> ...utf-8,html5.a.b.c.\input \detokenize{2000}
> nul 2>&1
*** (job aborted, file error in nonstop mode)
Here is how much of TeX's memory you used:
18 strings out of 478660
323 string characters out of 2852539
295553 words of memory out of 3000000
18228 multiletter control sequences out of 15000+600000
403430 words of font info for 27 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
12i,0n,19p,563b,10s stack positions out of 5000i,500n,10000p,200000b,80000s
No pages of output.
Uh, btw. i noticed that this backref issue not only affects html, it also affects .odt files
This is another issue, I am surprised that you haven't experienced it earlier. make4ht
has problem with (
and )
in filenames. I've found it when I tried your earlier example and fixed it in the development version, but it isn't on CTAN yet.
When trying to convert to odt, with make4ht --format odt --lua --loglevel debug 2021-08-13-BitcoinCrisesMonetarism.tex "mathml"
while using the new code for biblatex.4ht you posted above, the compilation failed and i got another error. See here: 2021-08-13-BitcoinCrisesMonetarism.log
When trying to convert with make4ht 2021-08-13-BitcoinCrisesMonetarism.tex "mathml"
, it does not work either.
2021-08-13-BitcoinCrisesMonetarism.log
When trying to convert with make4ht --lua 2021-08-13-BitcoinCrisesMonetarism.tex "mathml"
it did not work either. 2021-08-13-BitcoinCrisesMonetarism.log
These are the 3 files relevant for make4ht in my directory with the .tex file: biblatex.4ht.txt biblatex-chicago-hooks.4ht.txt usepackage.4ht.txt
I can compile the following example:
\documentclass{article}
\usepackage{lipsum}
\usepackage[noibid,backref=true,backrefstyle=three,eprint=false,authordate,backend=biber]{biblatex-chicago}
%\usepackage[footmarkoff,backend=biber]{biblatex-chicago}
%\usepackage[style=authoryear,citestyle=authoryear]{biblatex}
%\usepackage[style=numeric,citestyle=authoryear]{biblatex}
%\usepackage[style=MLA-new,sortcites=true,sorting=nyt]{biblatex}
%\usepackage[style=MLA-new,sortcites=true]{biblatex}
%\usepackage[style=APA,sortcites=true]{biblatex}
%IF backref=true, THEN one can also use this to replace "Cit. on pp":
\DefineBibliographyStrings{english}{
backrefpage={Cited on page},
backrefpages={Cited on pages}
}%
%IF backref=true, THEN to get backref line in a smaller font size use this:
%taken from: https://tex.stackexchange.com/
%questions/76133/bibliography-backref-on-new-line-with-smaller-font-size
\renewbibmacro*{pageref}{%
\addperiod% NEW
%adds a period at the end of the reference but ahead of backref
\iflistundef{pageref}
{}
%%{\printtext[parens]{% ORIGINAL BACKREF CODE
{\newline\footnotesize\printtext[parens]{% NEW
\ifnumgreater{\value{pageref}}{1}
{\bibstring{backrefpages}\ppspace}
{\bibstring{backrefpage}\ppspace}%
\printlist[pageref][-\value{listtotal}]{pageref}}}}% ORIGINAL BACKREF CODE
%%\printlist[pageref][-\value{listtotal}]{pageref}\addperiod}}}% NEW
%adds a period behind the page(s), such as "(cited on page x.)"
%
%
%Options for Backrefstyle (See Biblatex Documentation p. 52 and 53):
%backrefstyle=none
%no range of pages; only single pages shown
%backrefstyle=two
% 2 or more pages turn into a range of pages
%backrefstyle=three
% 3 or more pages turn into a range of pages
%backrefstyle=two+
%backrefstyle=three+
%backrefstyle=all+
%IF citestyle=authoryear THEN use the following:
\DeclareDelimFormat[textcite]{postnotedelim}{\addcolon\space}
%=Doppelpunkt nach dem Datum in textcite
%%\DeclareDelimFormat[textcite]{postnotedelim}{\addsemicolon\space}
%=Strichpunkt nach dem Datum in textcite
\DeclareDelimFormat[parencite]{postnotedelim}{\addcolon\space}
%=Doppelpunkt nach dem Datum in parencite
\DeclareFieldFormat{postnote}{\mknormrange{#1}}
\DeclareFieldFormat{multipostnote}{\mknormrange{#1}}
%erstellt individuelle Normrange um Zeichenfolge beim Zitieren zu ändern.
\addbibresource{bib_test_file.bib}
\usepackage[english]{babel}
\usepackage{ebgaramond}
\usepackage[autostyle,german=quotes]{csquotes}
\usepackage{hyperref}
\begin{document}
hello\autocite{trialurl1}
some text
again\autocite{trialurl1}
\lipsum[1-12]
hello\autocite{trialurl1}
\printbibliography
\end{document}
The bib_test_file.bib
file:
@misc{trialurl1,
author = {George, Birdie},
note = {\url{https://mail.yahoo.com/} Accessed 24 July 2020},
year = {2020},
}
@misc{trialurl2,
author = {George, Birdie},
title = {Hi},
note = {\url{https://mail.yahoo.com/} Accessed 24 July 2020},
year = {2020},
}
@book{vanier,
title = {Living Gently in a Violent World: The Prophetic Witness of Weakness},
author = {Vanier, Jean and Hauerwas, Stanley},
edition = {Second},
year = {2018},
publisher = {InterVarsity Press},
}
The log file seems like some patches for Biblatex-chicage are not active on your system. I can send you all .4ht
files from TeX4ht sources, to check if that helps.
I unfortunately sprained my ankle yesterday, so I will be a bit slower in my answers in next few days, as I need to rest :/
Yeah, i tried with your test file, and i could not compile. I would not know where and how to get the latest make4ht source files.
I wish you get better with your ankle though! Also, don't worry, it would be nice to have, but it is not super super super urgent on my end.
Have a happy Christmas time! :)
It is a bit difficult to get all TeX4ht source files, as they are generated from literate TeX files in the source repository. The files are here: 4htfiles.zip.
Thanks for your kind words, I wish you happy Christmas too!
Thank you! I tried it. It worked. It was good! Except ... one small thing:
--format odt
also worked! (similar behaviour as in the picture from last comment) :)
Except for this warning:
[WARNING] xtpipes: xtpipes failed trying tidy
Der Befehl "tidy" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
[WARNING] xtpipes: Tidy failed as well
1 Datei(en) verschoben.
1 Datei(en) verschoben.
[WARNING] xtpipes: xtpipes failed trying tidy
Der Befehl "tidy" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
[WARNING] xtpipes: Tidy failed as well
1 Datei(en) verschoben.
1 Datei(en) verschoben.
1 Datei(en) verschoben.
1 Datei(en) verschoben.
1 Datei(en) kopiert.
1 Datei(en) verschoben.
1 Datei(en) verschoben.
1 Datei(en) verschoben.
1 Datei(en) kopiert.
[STATUS] make4ht: Conversion finished
Ah yes and this little dot (. )
Hi Michal,
if you patch \blx@addbackref
instead of blx@backref
then backref
option is honored.
In the current version an anchor to cite in text (<a id="x1-2"></a>George <a href="#cite.0@trialurl1">2020</a>)
is always present regardless of backref
option.
Not that it is wrong per se, but I thought it would be cleaner to add anchors (like <a id="x1-2"></a>
) when they are needed.
The patch is trivial (in the sources):
\<biblatex backlinks\><<<
-\pend:defI\blx@backref{%
+\pend:defI\blx@addbackref{%
% prevent duplicate backlink on the same page
As a side effect, that would also fix my regression testing. Thanks.
Hi guys, sorry for the late reply, I needed to handle some more medical emergencies. I think I will be still slower in my answers in the next days, as I shouldn't work for too long.
Anyway, I think that I've tried the \blx@addbackref
macro first, but the patch isn't executed for some reason. You are right that the backlink destination is inserted regardless if the backref
option had been used.
Regarding the wrong rendering in the document, can you please post a full MWE? It doesn't happen for my test document.
I managed to track down the conditions for why some citations have a backref without link. There are two conditions:
This is the most minimal example i have found so far:
The bibliography (.bib) file:
@misc{trialurl1,
author = {George, Birdie},
note = {\url{https://mail.yahoo.com/} Accessed 24 July 2020},
year = {2020},
}
@misc{trialurl2,
author = {George, Birdie},
title = {Hi},
note = {\url{https://mail.yahoo.com/} Accessed 24 July 2020},
year = {2020},
}
@misc{trialurl3,
author = {George, Birdie},
title = {Hi},
note = {\url{https://mail.yahoo.com/} Accessed 24 July 2020},
year = {2020},
}
@misc{trialurl4,
author = {George, Birdie},
title = {Hi},
note = {\url{https://mail.yahoo.com/} Accessed 24 July 2020},
year = {2020},
}
@misc{trialurl5,
author = {George, Birdie},
title = {Hi},
note = {\url{https://mail.yahoo.com/} Accessed 24 July 2020},
year = {2020},
}
My preamble and text that triggers the malfunction:
\documentclass{article}
\usepackage{lipsum}
\usepackage[noibid,backref=true,backrefstyle=three,eprint=false,authordate,backend=biber]{biblatex-chicago}
\usepackage[english]{babel}
\usepackage{ebgaramond}
\usepackage[autostyle,german=quotes]{csquotes}
\usepackage{hyperref}
\addbibresource{bibliography.bib}
\begin{document}
random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text
random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text\footnote{footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test footnote test}text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random\autocite{trialurl1}, \autocite{trialurl2}, \autocite{trialurl3}, \autocite{trialurl4} random text random text random text.
\newpage
\pagenumbering{roman}
\setcounter{page}{1}
\printbibliography
\end{document}
Note how the citations are backrefed at page 2 in the html file, but if you compile as pdf they are shown to be on page 1 instead.
Have a good new year and may it be even better than the last one was! Hope your medical issues have dissolved itself 😁🎉✨
Are you able to reproduce? (using this MWE: https://github.com/michal-h21/make4ht/issues/58#issuecomment-1000961270)
Hi, thanks for reminding me of this issue, I lost track of the old issues.
I cannot reproduce it, links seem to be correct with current TeX4ht sources. Even the ODT file is correct. There was only one issue, spurious space after a backlink. But I fixed that in TeX4t sources.
See the attached HTML and ODT files: mwe.zip
Sorry, I can't seem to make it work on my side. It is even worse than back in the day, when i created the MWE, because back then I was able to compile.
Now, it will NOT compile if I do either one of these:
It WILL compile if I do this:
Unfortunately, it does not look at all as the file you uploaded. Here the files + log: filesandlog.zip
I am using these make4ht packages, WITHOUT the source files you sent me in one of the comments above:
Therefore, I only can assume that either I compile differently than you do, or you do have quite different source files as compared to what is downloadable on Miktex.
If I may ask, what method do you use to compile the .tex file before using make4ht? If there is any more information you would need of me or there is something unclear with the information I provided to you, just ask :)
Edit: I also installed the make4ht__source package. It did not help.
I see the issue now. It seems that it happens only with the --lua
option. It seems that wrong page number is written to the aux file. I've modified TeX4ht sources to delay wrinting of link, so it uses the same page number as BibLaTeX.
Try the attached 4htfiles.zip, especially biblatex.4ht
.
Ok, I tried again. Could not make it. Similar behaviour. Attached, you will find the whole directory with files BEFORE and AFTER using make4ht on it + Logs. I used the 4htfiles you sent me in your last comment and copied and pasted them all in the .tex directory. So to look for the output, just press t on your keyboard, as the .tex file is named "testthis".
For details, you could look at the files and the logs, but the short story is the same: Using latex > bibtex > latex > pdflatex before make4ht compiles, but it fails at embedding the links. Using lua > bibtex > lua > lua leads to critical error while compiling. For reference, testthis.pdf shows that both sequences definitely work for PDF (using Texmaker), just the transfer to html5 (or odt) fails.
(I also tried to use -d use/current/output
to set the output and make everything easier to find, but for some reason this also did not work for me, but this is a different topic, and maybe I did something wrong. Let's not dive deep into this, here in this thread)
Funny enough, when browsing the source files I noticed, how the changelog uses the wrong date: 2021 instead of 2022 for changes logged since 17th march. https://svn.gnu.org.ua/viewvc/tex4ht/trunk/lit/ChangeLog?view=markup&pathrev=1099
There is also one prioblem that I see in the LOG file:
Output written on 'testthis'.dvi (2 pages, 16076 bytes).
See the quotes around 'testdhis'
. It is caused by a bug in make4ht on Windows, and may lead to failing conversion. I've updated make4ht
to fix it, but it seems that the fix is not available in MikTeX yet. At least for the HTML mode, it should be possible to temporarily fix it by placing the updated mkparams.lua to the directory with your document. Or by installing the development version of make4ht
, at least temporarily.
Funny enough, when browsing the source files I noticed, how the changelog uses the wrong date: 2021 instead of 2022 for changes logged since 17th march.
Thanks for noticing this, I usually copy the changelog entries from previous records and change days and months, but didn't notice the wrong year.
Nice! Yes, mkparams.lua made the difference. I get same results as you now. So, it will be very good, when this arrives in MikTex. At least the MWE is working.
I still do have some trouble successfully compiling my larger document, but I am still trying to find out which package is the culprit. Will keep you updated.
That's great! This bug was here for several months because it affects only Windows. I got a bug report just last week, when it was already late for the fix to be included in TeX Live 2022 :/
Ah, since I used the babel package, i had to use the --lua
option.
html compiles successfully! -d
also works correctly now! Good job! My document looks almost perfect now, when using html as output! Almost. To 98% at least. Here, this is the only thing that is left to do:
html version via make4ht --lua -d use\current\output --loglevel debug myfile.tex
:
I will try to create a minimum (non-)working example again.
I suspect it has something to do with the reference having being cited on the same page twice, but I am not sure yet.
When clicking on the "8" from here:
then the link will not be opened and my screen will not be directed to the location of the reference on page 8, but the link in my browser changes. It adds the following numbers at the end of link...myfile.html:
myfile.html#x1-10003, x1-10005
Clicking on "8" from here it works normal and my screen is moved to the location of the reference.
Anyway, I am very happy we have come this far! I think at this stage, the conversion can already be used for most workflows 👍
Uoh, I just tried to convert to odt and it would not compile again :((((
Here the generic command I used: make4ht --format odt --lua myfile.tex
. Here
the log file
At the end of the log there are lines that say some files cannot be found.
I think that Babel should work even without --lua
option. But some language definition files declare various active characters, and it can break some things.
Regarding pages without links, I think it is because sometimes BibLaTeX puts multiple pages into the the macro that we use to insert links. It works only for the first number, not for the rest.
The odt
format has the same issue as we discussed previously. You can try to create directory formats
, and put file make4ht-odt.lua here.
Hmm ... still does not compile for odt.
I created a folder called formats
in my directory with the .tex file and put make4ht-odt.lua there.
I also tested the MWE from https://github.com/michal-h21/make4ht/issues/58#issuecomment-1000961270 and it does not compile for that one either, so I guess I am missing yet another file that exists in the source repository, but is not in miktex yet. I am not sure which issue you refer to we discussed previously. Do you refer to the file-name issue?
Here the log
Yes, the filename issue. Some files are copied incorrectly because of spurious quotes. I think the format file is the only one necessary for correct running, but it seems that it isn't used even if you place it in the formats
subdirectory. You can then try to install the development version of make4ht and then remove it once Miktex updates.
Alright. I will wait until your changes make it to Miktex, then test the odt conversion again and report back to you. Thank you so far :)
I hope it will not take too long, I think Miktex updates quite frequently.
Yesterday, I updated to the newest development version of make4ht on miktex (version 0.3l) and it compiles odt again.
compiling the MWE from https://github.com/michal-h21/make4ht/issues/58#issuecomment-1000961270 via lua > bibtex (biber) > lua > lua and then converting via make4ht --format odt --lua -d odt --loglevel debug testthis.tex
the outcome is thus:
compiling my larger document with same commands yields:
hmmm. Neverending story xD
Shall I wait some more, until more files are pushed to miktex, or should I do some debugging?
I think this will need some debugging.
Putting the biblatex.4ht file you sent me in comment https://github.com/michal-h21/make4ht/issues/58#issuecomment-1078885519 into the folder with the .tex file, makes conversions to html AND odt work better (by creating a lot more links).
So I guess the main problem is that this file is still not in MikTeX.
Ah, that's good to hear. MikTeX updates .4ht files only occasionally, so it can take some time before they are available :/
Ahhhh, ok. Will wait some more then.
I can't find the commit of you having changed the file here on GitHub btw.
Edit: make4ht version v0.3j
For the simple command
make4ht file.tex "mathml"
i experience that backref with a pagenumber is generated, but when clicking on the cross-reference, nothing happens.my backref, biblatex and hyperref commands
``` \usepackage[noibid,backref=true,backrefstyle=three,eprint=false,authordate,backend=biber]{biblatex-chicago} \DefineBibliographyStrings{english}{ backrefpage={Cited on page}, backrefpages={Cited on pages} } %IF backref=true, THEN to get backref line in a smaller font size use this: %taken from: https://tex.stackexchange.com/ %questions/76133/bibliography-backref-on-new-line-with-smaller-font-size \renewbibmacro*{pageref}{% \addperiod \iflistundef{pageref} {} {\newline\footnotesize\printtext[parens]{ \ifnumgreater{\value{pageref}}{1} {\bibstring{backrefpages}\ppspace} {\bibstring{backrefpage}\ppspace}% \printlist[pageref][-\value{listtotal}]{pageref}}}} \usepackage[plainpages=false,hypertexnames=true]{hyperref} \hypersetup{ colorlinks = true, linkcolor = blue, citecolor = blue, urlcolor = blue } ```the cross-reference of the page-numbers point to this: filepath/file.html#page.xyz
This is how it is formated:
It looks nice, but oh well...
Additional Info: