# \appendix command affecting footnote in TeX4ht

In my document, I need all footnotes should come at the end of each chapter, for this I write a cfg file and all the codes are given below:

**test.cfg:**

\Preamble{xhtml,fn-in}

\HAssign\ChapId=0%
\Configure{chapter}{}{}{\ifvmode\IgnorePar\fi\EndP%
\expandafter\ifvoid\csname fn:box\endcsname\else%
\HCode{<div class="footnotes">}\expandafter\box\csname%
\fi%
\HCode{<p class="CN">}\TitleMark\HCode{</p>\Hnewline<p class="CT">}%
}{\HCode{</p>}\IgnoreIndent}%

% PN and PT Changes in CFG %

\Configure{part}{}{}{\ifvmode\IgnorePar\fi\EndP%
\expandafter\ifvoid\csname fn:box\endcsname\else%
\HCode{<div class="footnotes">}\expandafter\box\csname%
fn:box\endcsname\HCode{</div>}%
\fi%
\HCode{<p class="PN">}\partname \ \thepart%
\HCode{</p>\Hnewline<p class="PT">}%
}{\HCode{</p>}\IgnoreIndent}%

% FMH Changes in CFG %

\Configure{likechapter}{}{}{\ifvmode\IgnorePar\fi\EndP%
\expandafter\ifvoid\csname fn:box\endcsname\else%
\HCode{<div class="footnotes">}\expandafter\box\csname%
fn:box\endcsname\HCode{</div>}%
\fi%
\HCode{<p class="FMH">}\TitleMark%
}{\HCode{</p>}\par}%

\begin{document}

\EndPreamble


TeX file content:

\documentclass{book}
\usepackage[toc,page]{appendix}
\begin{document}

\chapter{Chapter One}

Third chapter text goes here\footnote{Footnote text}

\appendix

\begin{appendices}
\chapter{Scalars, Vectors, and Tensors}

Coordinate $,;:.$ systems, or reference frames, are not part of nature.
They are maps introduced by us.  Whenever we project a problem
onto a set of coordinates, we must distinguish features intrinsic
to the physical system from artifacts that arise from the
coordinate system.  Whenever we shift from one coordinate map to
another, we must understand what stays the same and what changes
and how.\footnote{Footnote test}  The principles that tell us how to convert quantities
and relationships between coordinate systems are theories of
relativity.

\chapter{Third Chapter}

This is for test for footnote in Chapter\footnote{Footnote in Chapter}
\end{appendices}

\end{document}


Converting command"

htlatex test "test,xhtml,fn-in" " -cunihft" "-cvalidate -p"


Now all the footnote came end of the last chapter, see the screenshot below:

but my requirement is relevant footnotes to come at the end of the relevant chapters. Note that my requirement is working fine without Appendices, problem happened only Appendix comes. Please suggest...

Now, the Appendix problem solved by using the below tag in .cfg file:

%%Appendix%%
\Configure{appendix}{}{}
{\ifvmode\IgnorePar\fi\EndP%
\expandafter\ifvoid\csname fn:box\endcsname\else%
\HCode{<div class="footnotes">}\expandafter\box\csname%
fn:box\endcsname\HCode{</div>}\fi%
\if@mainmatter \TitleMark{\HCode{<br />}}\fi }
{\HCode{</h2>}\IgnoreIndent}


Now its coming fine, but the last chapter footnote came after the head "Appendix", also the text "Appendix A", "Appendix B" didn't come, please refer the below screenshot:

How to fix my requirement?

First of all, I would put the code that prints the footnotes to macro, in order to make the configurations cleaner. To your actual issue, you print the footnotes only at chapters, but the \begin{appendices} inserts Appendices title before the footnotes for the previous chapters can be printed. So you need to call the footnote printing code as soon as you enter \appendix. For example by patching the \appendix command:

\Preamble{xhtml,fn-in}

\def\printfnbox{%
\expandafter\ifvoid\csname fn:box\endcsname\else%
\HCode{<div class="footnotes">}\expandafter\box\csname%
fn:box\endcsname\HCode{</div>}%
\fi%
}

\HAssign\ChapId=0%
\Configure{chapter}{}{}{\ifvmode\IgnorePar\fi\EndP%
\expandafter\ifvoid\csname fn:box\endcsname\else%
\fi%
\HCode{<p class="CN">}\TitleMark\HCode{</p>\Hnewline<p class="CT">}%
}{\HCode{</p>}\IgnoreIndent}%

% PN and PT Changes in CFG %

\Configure{part}{}{}{\ifvmode\IgnorePar\fi\EndP%
\printfnbox%
\HCode{<p class="PN">}\partname \ \thepart%
\HCode{</p>\Hnewline<p class="PT">}%
}{\HCode{</p>}\IgnoreIndent}%

% FMH Changes in CFG %

\Configure{likechapter}{}{}{\ifvmode\IgnorePar\fi\EndP%
\printfnbox%
\HCode{<p class="FMH">}\TitleMark%
}{\HCode{</p>}\par}%

\Configure{appendix}{}{}
{\ifvmode\IgnorePar\fi\EndP%
\printfnbox%
\TitleMark{\HCode{<br />}}}
{\HCode{</h2>}\IgnoreIndent}

\begin{document}

\EndPreamble
\let\oldappendix\appendix
\def\appendix{\ifvmode\IgnorePar\fi\EndP\printfnbox\oldappendix}


This is the result:

Note that \chapter doesn't produce tags for HTML section, but only ordinary paragraphs, so it is not highlighted. I don't know whether this is your intention, but it is configured this way in your code, so I guess that it is correct?

• Sir, your valuable suggestion is working fine for my requirement, only thing is Appendix number, i.e., "Appendix A" and "Appendix B" was missing, how can I achieve this? – MadyYuvi Aug 17 '17 at 9:53