3

I would like to convert my edition of Arabic text into ODT format. The edition uses notes that are supposed appear in a smaller font in a paragraph below the text (not at the bottom of each page). I would like the footnote hooks to be in Arabic-style numerals ١٢٣٤٥٦٧٨٩٠ rather than Roman-style numerals 1234567890. Ideally I would like to be able to select the font (Amiri) to which it will output (current default is Tahoma for the Arabic text).

What I haven't been able to figure out is

  1. how to make the footnote hooks Arabic-style
  2. how to make the notes paragraph a much smaller font size
  3. how to remove a spurious space that comes after the footnote marker in the notes paragraph.

How can I do this?

MWE

myfile.tex:

\documentclass[12pt,letterpaper,oldfontcommands]{memoir}

\usepackage{fontspec}
\usepackage{xunicode}
\usepackage[T1]{fontenc}

\newcommand{%
\خ%
    }[2]{%
    \ar{#1}\footnoteA{\ar{#1%
    :
    #2}}%
    }

\newfontfamily\arabicfont[Script=Arabic,Mapping=arabicdigits]{Amiri}

%Arabic
\newcommand{\ar}[1]{#1}
\newenvironment{arab}{}{}

% APPARATUS FOR VARIANTS IN ARABIC TEXT
\usepackage[para]{manyfoot}
\SetFootnoteHook{\setRL}
\DeclareNewFootnote[para]{A}[alph]

%%%%%%%%%%%%%%%%%%%%%%%%%%
% Placing Arabic apparatus at the end of each paragraph
% (WARNING !!! :  currently only works if VARIANT commands only come within `arab` environments)
\usepackage[restart]{parnotes} % package
\renewcommand{\parnotefmt}[1]{\tiny\noindent #1}
\renewcommand{\footnoteA}[1]{\parnote{#1}} % mk app fns parnotes
% \renewcommand*{\parnotecusmarkfmt}[1]{\arabicfont\addfontfeature{Mapping=arabicdigits}\textsuperscript{#1}}
\renewcommand*{\parnotecusmarkfmt}[1]{\arabicfont\addfontfeature{Mapping=arabicdigits}\textsuperscript{#1}}

\let\origArab\arab
\renewenvironment{arab}{\begin{origArab}}{\parnotes{}\end{origArab}} % make arab environment print parnotes at the end
%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\begin{arab}
\خ{لكن لما}{ڤ؛ إنني كلما: ي}
\end{arab}
\end{document}

Compiled with

make4ht -uxm draft -f odt -c myconfig.cfg

where myconfig.cfg is:

\Preamble{xhtml}
\ConfigureOO{Footnote}{
<style:style
    style:name="Footnote"
    style:family="paragraph"
    style:parent-style-name="Standard"
    style:class="extra">\Hnewline
  <style:paragraph-properties
             fo:margin-left="0in"
             fo:margin-right="0in"
             fo:text-indent="0.1in"
              style:auto-text-indent="false"/>
  <style:text-properties fo:font-size="83.3333333333333333333333\%"
      style:font-size-asian="83.3333333333333333333333\%"
      style:font-size-complex="83.3333333333333333333333\%" />
</style:style>\Hnewline
<text:notes-configuration text:note-class="footnote"
    text:citation-style-name="Footnote_20_Symbol"
    text:citation-body-style-name="Footnote_20_anchor"
    style:num-format="1" text:start-value="0"
    text:footnotes-position="page"
    text:start-numbering-at="document" />\Hnewline
<style:style style:name="Footnote_20_Symbol"
style:display-name="Footnote Symbol" style:family="text" >\Hnewline
  <style:text-properties style:text-position="super 58\%" />\Hnewline
</style:style>
<style:style style:name="Footnote_20_anchor"
style:display-name="Footnote anchor" style:family="text">
  <style:text-properties style:text-position="super 58\%" />\Hnewline
</style:style>\Hnewline
}

\ConfigureOO{verse}{\Hnewline
<style:style style:name="verse"
             style:family="paragraph"
             style:parent-style-name="Text-body"
             style:next-style-name="Text-body">
<style:paragraph-properties  fo:margin-left="1.499cm"
             fo:margin-right="1cm"
             fo:margin-top="0cm"
             fo:margin-bottom="0cm"
             fo:text-indent="-0.499cm"
             style:auto-text-indent="false">
   <style:tab-stops/>
</style:paragraph-properties >
</style:style>
\Hnewline}

\xeuniuseblock{Greek}
\xeuniuseblock{Arabic}
\makeatletter
\ConfigureEnv{arab}{\@rltrue}{\@rlfalse}{}{}
\Configure{ref}{\Link}{\EndLink}{}
\makeatother
\begin{document}
\EndPreamble

current output

enter image description here

desired output

enter image description here

21
  • 1
    there is no configuration for the manyfoot package, so the footnotes came as a normal paragraph. I will look at this issue next week, I will be offline next few days
    – michal.h21
    Jun 14, 2019 at 7:49
  • 1
    Okay, after a bit of mucking around, a couple problems: 1: You aren’t using manyfoot, because you simply redefine \footnoteA to call \parnote.
    – Davislor
    Jun 14, 2019 at 14:08
  • 1
    2. Because you call \parnote instead of \footnote, your \ConfigureOO{footnote}, etc., never get called.
    – Davislor
    Jun 14, 2019 at 14:09
  • 1
    3. Changing the font to Amiri within the document has no effect. (I believe you can add the fo:font-family attribute to the relevant redefinitions in your .cfg file.)
    – Davislor
    Jun 14, 2019 at 14:12
  • 1
    4. The command to get Arabic-script numerals is incorrect anyway, but also is being ignored by tex4ht. I believe the correct approach is to load \babel, \babelprovide[main, import]{arabic}, and then use its \arabicdigits command.
    – Davislor
    Jun 14, 2019 at 14:15

1 Answer 1

1
+50

Your original TeX file doesn't compile correctly with XeLaTeX or LuaLaTeX. Here is a modified version that compiles with both of them:

% https://tex.stackexchange.com/q/495709/2891
\documentclass[12pt,letterpaper,oldfontcommands]{memoir}

\usepackage{fontspec}
% \usepackage{xunicode}
% \usepackage[T1]{fontenc}
\ifdefined\HCode
  \usepackage{babel}
\else
\ifdefined\directlua
\usepackage[nil,bidi=basic-r]{babel}
\babelprovide[import=ar,main]{arabic}
\babelfont[arabic]{rm}{Amiri}
\else
% \usepackage[]{babel}
\usepackage{polyglossia}
\setmainlanguage{arabic}
%\setotherlanguage{arabic}
\fi
\fi

\newcommand{%
\خ%
    }[2]{%
    \ar{#1}\footnoteA{\ar{#1%
    :
    #2}}%
    }

% \newfontfamily\arabicfont[Script=Arabic,Mapping=arabicdigits]{Amiri}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}

%Arabic
\newcommand{\ar}[1]{\bgroup\arabicfont#1\egroup}
\newenvironment{arab}{}{}

% APPARATUS FOR VARIANTS IN ARABIC TEXT
\usepackage[para]{manyfoot}
\SetFootnoteHook{\setRL}
\DeclareNewFootnote[para]{A}[alph]

%%%%%%%%%%%%%%%%%%%%%%%%%%
% Placing Arabic apparatus at the end of each paragraph
% (WARNING !!! :  currently only works if VARIANT commands only come within `arab` environments)
\usepackage[restart]{parnotes} % package
\renewcommand{\parnotefmt}[1]{\tiny\noindent #1}
\renewcommand{\footnoteA}[1]{\parnote{#1}} % mk app fns parnotes
% \renewcommand*{\parnotecusmarkfmt}[1]{\arabicfont\addfontfeature{Mapping=arabicdigits}\textsuperscript{#1}}
\renewcommand*{\parnotecusmarkfmt}[1]{\arabicfont\textsuperscript{\arabicdigits{#1}}}

\let\origArab\arab
\renewenvironment{arab}{\begin{origArab}}{\parnotes{}\end{origArab}} % make arab environment print parnotes at the end
%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\begin{arab}
\خ{لكن لما}{ڤ؛ إنني كلما: ي}
\end{arab}

\end{document}

I've made few changes:

% \usepackage{xunicode}
% \usepackage[T1]{fontenc}
\ifdefined\HCode
  \usepackage{babel}
\else
\ifdefined\directlua
\usepackage[nil,bidi=basic-r]{babel}
\babelprovide[import=ar,main]{arabic}
\babelfont[arabic]{rm}{Amiri}
\else
% \usepackage[]{babel}
\usepackage{polyglossia}
\setmainlanguage{arabic}
%\setotherlanguage{arabic}
\fi
\fi

With tex4ht only babel package is required, with no language definitions, with LuaLaTeX and XeLaTeX babel or polyglossia with options for correct text directions are used.

Another change is to parnotes mark:

\renewcommand*{\parnotecusmarkfmt}[1]{\arabicfont\textsuperscript{\arabicdigits{#1}}}

The change is that it uses the \arabicdigits command instead of relying on the XeLaTeX font mapping mechanism. Thanks to this change, it works with LuaLaTeX.

The configuration file needed only a small change:

\Preamble{xhtml,ooffice}
\ConfigureOO{Footnote}{
<style:style
    style:name="Footnote"
    style:family="paragraph"
    style:parent-style-name="Standard"
    style:class="extra">\Hnewline
  <style:paragraph-properties
             fo:margin-left="0in"
             fo:margin-right="0in"
             fo:text-indent="0.1in"
              style:auto-text-indent="false"/>
  <style:text-properties fo:font-size="83.3333333333333333333333\%"
      style:font-size-asian="83.3333333333333333333333\%"
      style:font-size-complex="83.3333333333333333333333\%" />
</style:style>\Hnewline
<text:notes-configuration text:note-class="footnote"
    text:citation-style-name="Footnote_20_Symbol"
    text:citation-body-style-name="Footnote_20_anchor"
    style:num-format="1" text:start-value="0"
    text:footnotes-position="page"
    text:start-numbering-at="document" />\Hnewline
<style:style style:name="Footnote_20_Symbol"
style:display-name="Footnote Symbol" style:family="text" >\Hnewline
  <style:text-properties style:text-position="super 58\%" />\Hnewline
</style:style>
<style:style style:name="Footnote_20_anchor"
style:display-name="Footnote anchor" style:family="text">
  <style:text-properties style:text-position="super 58\%" />\Hnewline
</style:style>\Hnewline
}

\ConfigureOO{verse}{\Hnewline
<style:style style:name="verse"
             style:family="paragraph"
             style:parent-style-name="Text-body"
             style:next-style-name="Text-body">
<style:paragraph-properties  fo:margin-left="1.499cm"
             fo:margin-right="1cm"
             fo:margin-top="0cm"
             fo:margin-bottom="0cm"
             fo:text-indent="-0.499cm"
             style:auto-text-indent="false">
   <style:tab-stops/>
</style:paragraph-properties >
</style:style>
\Hnewline}

\def\loopoverdigits#1{\ifx\relax#1\else%
% Unicode block for Arabic numerals starts at U+0660
% the following special command inserts the XML entity
% for the number, which will be converted to Unicode char
% by tex4ht
\special{t4ht@+&{35}x066#1{59}}x%
\expandafter\loopoverdigits\fi}

\def\arabicdigits#1{\NoFonts\loopoverdigits#1\relax\EndNoFonts}
\ifdefined\xeuniuseblock
\xeuniuseblock{Greek}
\xeuniuseblock{Arabic}
\fi
\makeatletter
\ConfigureEnv{arab}{\@rltrue}{\@rlfalse}{}{}
\Configure{ref}{\Link}{\EndLink}{}
\makeatother
\begin{document}
\EndPreamble

I've added modified definition for \arabicdigits:

\def\loopoverdigits#1{\ifx\relax#1\else%
% Unicode block for Arabic numerals starts at U+0660
% the following special command inserts the XML entity
% for the number, which will be converted to Unicode char
% by tex4ht
\special{t4ht@+&{35}x066#1{59}}x%
\expandafter\loopoverdigits\fi}

\def\arabicdigits#1{\NoFonts\loopoverdigits#1\relax\EndNoFonts}

It loops over all digits in the argument and prints them as a Unicode entity, using the \special{t4ht@+&{35}x066#1{59}}x command. It utilizes the fact, that the Arabic numbers start at 0660 codepoint, so we can just pass the number as the last digit in the codepoint and it will end as a correct Unicode value.

Here is the result in LO:

enter image description here

4
  • Wonderful, thank you very much! This works perfectly. Is there any way to adjust the customization file slightly so that there is no space after the parnote anchor (as in my original image of the desired output)? Likewise -- though this should probably be a separate question -- I would like to be able to customize the space between each parnote, e.g., to add 5 spaces rather than a single space after each parnote. In any case, thank you again for making this work! Jul 11, 2019 at 4:55
  • 1
    @AlexRoberts I guess the space after parnote may be caused by a missing % at the end of line somewhere in the configurations. Other stuff can be fixed using the OO styles, I think. I will be offline for next week, so I cannot test it more.
    – michal.h21
    Jul 11, 2019 at 7:22
  • My temporary workaround is to have each parnote add "PARNOTESTART" at the beginning and "PARNOTEEND" at the end. Then I use the word processor's "Find/Replace" to replace a space+ PARNOTESTART with nothing and to replace PARNOTEEND with five spaces. This still saves tons of time! Jul 21, 2019 at 18:14
  • @AlexRoberts it still seems like a lot of unnecessary work. I cannot find the source of the space though :(
    – michal.h21
    Jul 21, 2019 at 19:19

You must log in to answer this question.

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