I'm trying to generate an .epub with tex4ebook. One of the commands I've defined uses \ifelsethen and \isempty to check for empty parameters and produce different output depending on which parameters are present:
- If the first parameter is empty, it should print "empty1".
- If the first parameter is not empty, but the second is empty, it should print "parameter#1 empty2".
- If both parameters are present, it should print both.
I also need to be able to add a footnote to either parameter, and I use biblatex to handle references. However, this command doesn't work correctly if I use biblatex, as I've shown in the mwe below. I would appreciate any hints for how to get xifthen functions to work with biblatex or suggestions for alternatives to \ifthenelse and \isempty that are compatible with biblatex.
mwe.tex
\documentclass{book}
%\usepackage{biblatex}
\usepackage{xifthen}
\newcommand{\printif}[2]{\ifthenelse{\isempty{#1}}{empty1}{#1\ifthenelse{\isempty{#2}}{ empty2}{ #2}}}
\begin{document}
\printif{apple\footnotemark[1]}{orange}
\printif{pear}{peach}
\footnotetext[1]{This is a footnote.}
\end{document}
Both of the examples in the mwe work as expected if I don't import biblatex.
If I import biblatex and comment out the first example, the document compiles, but the output is incorrect: the first parameter and the text that's supposed to be printed if the first parameter is empty are both present in the .epub.
part of mwe.log (with biblatex, only second example)
Package biblatex Info: Trying to load citation style 'numeric'...
Package biblatex Info: ... file 'numeric.cbx' found.
(/usr/share/texmf-dist/tex/latex/biblatex/cbx/numeric.cbx
File: numeric.cbx 2020/08/23 v3.15a biblatex citation style (PK/MW)
Package biblatex Info: Redefining '\cite'.
Package biblatex Info: Redefining '\parencite'.
Package biblatex Info: Redefining '\footcite'.
Package biblatex Info: Redefining '\footcitetext'.
Package biblatex Info: Redefining '\smartcite'.
Package biblatex Info: Redefining '\supercite'.
Package biblatex Info: Redefining '\textcite'.
Package biblatex Info: Redefining '\textcites'.
Package biblatex Info: Redefining '\cites'.
Package biblatex Info: Redefining '\parencites'.
Package biblatex Info: Redefining '\smartcites'.
)
Package biblatex Info: Trying to load configuration file...
Package biblatex Info: ... file 'biblatex.cfg' found.
(/usr/share/texmf-dist/tex/latex/biblatex/biblatex.cfg
File: biblatex.cfg
)) (/usr/share/texmf-dist/tex/latex/xifthen/xifthen.sty
Package: xifthen 2015/11/05 v1.4.0 Extended ifthen features
(/usr/share/texmf-dist/tex/latex/tools/calc.sty
Package: calc 2017/05/25 v4.3 Infix arithmetic (KKT,FJ)
\calc@Acount=\count382
\calc@Bcount=\count383
\calc@Adimen=\dimen141
\calc@Bdimen=\dimen142
\calc@Askip=\skip71
\calc@Bskip=\skip72
LaTeX Info: Redefining \setlength on input line 80.
LaTeX Info: Redefining \addtolength on input line 81.
\calc@Ccount=\count384
\calc@Cskip=\skip73
) (/usr/share/texmf-dist/tex/latex/ifmtarg/ifmtarg.sty
Package: ifmtarg 2018/04/16 v1.2b check for an empty argument
)) (./mwe.cfg (/usr/share/texmf-dist/tex/generic/tex4ht/tex4ht.4ht
version 2020-03-12-14:03
--------------------------------------
::::::::::::::::::::::::::::::::::::::::::
TeX4ht info is available in the log file
::::::::::::::::::::::::::::::::::::::::::
--------------------------------------
(/usr/share/texmf-dist/tex/generic/tex4ht/html4-uni.4ht)) (/usr/share/texmf-d
ist/tex/generic/tex4ht/biblatex.4ht
version 2020-10-05-15:22
\sv:sec:cnt=\count388
\c@bib=\count389
LaTeX Info: Redefining \MakeUppercase on input line 206.
LaTeX Info: Redefining \MakeLowercase on input line 214.
\blx@unitmark=\skip75
--------------------------------------
Package biblatex Warning: Patching footnotes failed.
(biblatex) Footnote detection will not work.
\@quotelevel=\count390
\@quotereset=\count391
(./mwe.aux)
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
Package biblatex Info: Trying to load language 'english'...
Package biblatex Info: ... file 'english.lbx' found.
(/usr/share/texmf-dist/tex/latex/biblatex/lbx/english.lbx
File: english.lbx 2020/08/23 v3.15a biblatex localization (PK/MW)
)
Package biblatex Info: Input encoding 'utf8' detected.
Package biblatex Info: Automatic encoding selection.
(biblatex) Assuming data encoding 'utf8'.
Package biblatex Info: Trying to load bibliographic data...
Package biblatex Info: ... file 'mwe.bbl' not found.
No file mwe.bbl.
Package biblatex Info: Reference section=0 on input line 3.
Package biblatex Info: Reference segment=0 on input line 3.
--- file mwe.css ---
)
! Undefined control sequence.
<inserted text> \isempty
{pear}
l.13 \printif{pear}{peach}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Missing number, treated as zero.
<to be read again>
{
l.13 \printif{pear}{peach}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Missing = inserted for \ifnum.
<to be read again>
{
l.13 \printif{pear}{peach}
I was expecting to see `<', `=', or `>'. Didn't.
! Missing number, treated as zero.
<to be read again>
{
l.13 \printif{pear}{peach}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
(./mwe.4ct) [1
] (./mwe.aux)
LaTeX Warning: There were undefined references.
Package biblatex Warning: Please (re)run Biber on the file:
(biblatex) mwe
(biblatex) and rerun LaTeX afterwards.
Package logreq Info: Writing requests to 'mwe.run.xml'.
)
Output written on mwe.dvi (1 page, 15248 bytes).
If I import biblatex and don't comment out the first example, the document doesn't compile.
part of mwe.log (with biblatex, only first \printif example)
Package biblatex Info: Trying to load citation style 'numeric'...
Package biblatex Info: ... file 'numeric.cbx' found.
(/usr/share/texmf-dist/tex/latex/biblatex/cbx/numeric.cbx
File: numeric.cbx 2020/08/23 v3.15a biblatex citation style (PK/MW)
Package biblatex Info: Redefining '\cite'.
Package biblatex Info: Redefining '\parencite'.
Package biblatex Info: Redefining '\footcite'.
Package biblatex Info: Redefining '\footcitetext'.
Package biblatex Info: Redefining '\smartcite'.
Package biblatex Info: Redefining '\supercite'.
Package biblatex Info: Redefining '\textcite'.
Package biblatex Info: Redefining '\textcites'.
Package biblatex Info: Redefining '\cites'.
Package biblatex Info: Redefining '\parencites'.
Package biblatex Info: Redefining '\smartcites'.
)
Package biblatex Info: Trying to load configuration file...
Package biblatex Info: ... file 'biblatex.cfg' found.
(/usr/share/texmf-dist/tex/latex/biblatex/biblatex.cfg
File: biblatex.cfg
)) (/usr/share/texmf-dist/tex/latex/xifthen/xifthen.sty
Package: xifthen 2015/11/05 v1.4.0 Extended ifthen features
(/usr/share/texmf-dist/tex/latex/tools/calc.sty
Package: calc 2017/05/25 v4.3 Infix arithmetic (KKT,FJ)
\calc@Acount=\count382
\calc@Bcount=\count383
\calc@Adimen=\dimen141
\calc@Bdimen=\dimen142
\calc@Askip=\skip71
\calc@Bskip=\skip72
LaTeX Info: Redefining \setlength on input line 80.
LaTeX Info: Redefining \addtolength on input line 81.
\calc@Ccount=\count384
\calc@Cskip=\skip73
) (/usr/share/texmf-dist/tex/latex/ifmtarg/ifmtarg.sty
Package: ifmtarg 2018/04/16 v1.2b check for an empty argument
)) (./mwe.cfg (/usr/share/texmf-dist/tex/generic/tex4ht/tex4ht.4ht
version 2020-03-12-14:03
--------------------------------------
::::::::::::::::::::::::::::::::::::::::::
TeX4ht info is available in the log file
::::::::::::::::::::::::::::::::::::::::::
--------------------------------------
(/usr/share/texmf-dist/tex/generic/tex4ht/biblatex.4ht
version 2020-10-05-15:22
\sv:sec:cnt=\count388
\c@bib=\count389
LaTeX Info: Redefining \MakeUppercase on input line 206.
LaTeX Info: Redefining \MakeLowercase on input line 214.
\blx@unitmark=\skip75
Package biblatex Warning: Patching footnotes failed.
(biblatex) Footnote detection will not work.
\@quotelevel=\count390
\@quotereset=\count391
No file mwe.aux.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
Package biblatex Info: Trying to load language 'english'...
Package biblatex Info: ... file 'english.lbx' found.
(/usr/share/texmf-dist/tex/latex/biblatex/lbx/english.lbx
File: english.lbx 2020/08/23 v3.15a biblatex localization (PK/MW)
)
Package biblatex Info: Input encoding 'utf8' detected.
Package biblatex Info: Automatic encoding selection.
(biblatex) Assuming data encoding 'utf8'.
Package biblatex Info: Trying to load bibliographic data...
Package biblatex Info: ... file 'mwe.bbl' not found.
No file mwe.bbl.
Package biblatex Info: Reference section=0 on input line 3.
Package biblatex Info: Reference segment=0 on input line 3.
--- file mwe.css ---
)
! Undefined control sequence.
<inserted text> \isempty
{apple\footnotemark [1]}
l.11 \printif{apple\footnotemark[1]}{orange}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Argument of \:Advance has an extra }.
<inserted text>
\par
l.11 \printif{apple\footnotemark[1]}{orange}
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.
Runaway argument?
! Paragraph ended before \:Advance was complete.
<to be read again>
\par
l.11 \printif{apple\footnotemark[1]}{orange}
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
! Argument of \reserved@a has an extra }.
<inserted text>
\par
l.11 \printif{apple\footnotemark[1]}{orange}
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.
Runaway argument?
]
! Paragraph ended before \reserved@a was complete.
<to be read again>
\par
l.11 \printif{apple\footnotemark[1]}{orange}
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
! Missing number, treated as zero.
<to be read again>
{
l.11 \printif{apple\footnotemark[1]}{orange}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Missing = inserted for \ifnum.
<to be read again>
{
l.11 \printif{apple\footnotemark[1]}{orange}
I was expecting to see `<', `=', or `>'. Didn't.
! Missing number, treated as zero.
<to be read again>
{
l.11 \printif{apple\footnotemark[1]}{orange}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Missing control sequence inserted.
<inserted text>
\inaccessible
l.11 \printif{apple\footnotemark[1]}{orange}
Please don't say `\def cs{...}', say `\def\cs{...}'.
I've inserted an inaccessible control sequence so that your
definition will be completed without mixing me up too badly.
You can recover graciously from this error, if you're
careful; see exercise 27.2 in The TeXbook.
! Missing number, treated as zero.
<to be read again>
\bgroup
l.11 \printif{apple\footnotemark[1]}{orange}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Missing number, treated as zero.
<to be read again>
\afterassignment
l.11 \printif{apple\footnotemark[1]}{orange}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Missing number, treated as zero.
<to be read again>
\xdef
l.11 \printif{apple\footnotemark[1]}{orange}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Missing number, treated as zero.
<to be read again>
\def
l.11 \printif{apple\footnotemark[1]}{orange}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Missing control sequence inserted.
<inserted text>
\inaccessible
l.11 \printif{apple\footnotemark[1]}{orange}
Please don't say `\def cs{...}', say `\def\cs{...}'.
I've inserted an inaccessible control sequence so that your
definition will be completed without mixing me up too badly.
You can recover graciously from this error, if you're
careful; see exercise 27.2 in The TeXbook.
! Missing number, treated as zero.
<to be read again>
{
l.11 \printif{apple\footnotemark[1]}{orange}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Missing control sequence inserted.
<inserted text>
\inaccessible
l.11 \printif{apple\footnotemark[1]}{orange}
Please don't say `\def cs{...}', say `\def\cs{...}'.
I've inserted an inaccessible control sequence so that your
definition will be completed without mixing me up too badly.
You can recover graciously from this error, if you're
careful; see exercise 27.2 in The TeXbook.
! Missing { inserted.
\@gtempa ...nt by 1 \let \reserved@d =[\def \par }
\relax \TE@setvaltrue \els...
l.11 \printif{apple\footnotemark[1]}{orange}
Where was the left brace? You said something like `\def\a}',
which I'm going to interpret as `\def\a{}'.
! Use of \let doesn't match its definition.
\TE@valtrue ->\let \ifTE@val
\iftrue
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! Extra \else.
\@gtempa ...def \par }\relax \TE@setvaltrue \else
\TE@setvalfalse \fi \TE@ne...
l.11 \printif{apple\footnotemark[1]}{orange}
I'm ignoring this; it doesn't match any \if.
! Use of \let doesn't match its definition.
\TE@setvalfalse ->\let \ifTE@val
\ifTE@negate
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! Use of \let doesn't match its definition.
\TE@negatefalse ->\let \ifTE@negate
\iffalse
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! Use of \let doesn't match its definition.
\:ssg #1#2->\let \d:fn
#1\def \:var {#2}\futurelet \:temp \:Assgn
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! Use of \let doesn't match its definition.
\ip:op #1#2->\let \mth:op
#1\let \adv:c #2\adv:
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! Use of \let doesn't match its definition.
\ip:op #1#2->\let \mth:op #1\let \adv:c
#2\adv:
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! You can't use `begin-group character {' after \advance.
\:Advance #1->\bgroup
\def \:temp {#1}\tmp:cnt #1\afterassignment \:aplus \m...
l.11 \printif{apple\footnotemark[1]}{orange}
I'm forgetting what you said and not changing anything.
! Use of \def doesn't match its definition.
\:Advance #1->\bgroup \def \:temp
{#1}\tmp:cnt #1\afterassignment \:aplus \m...
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! Argument of \adv: has an extra }.
<inserted text>
\par
l.11 \printif{apple\footnotemark[1]}{orange}
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.
Runaway argument?
! Paragraph ended before \adv: was complete.
<to be read again>
\par
l.11 \printif{apple\footnotemark[1]}{orange}
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
! Use of \def doesn't match its definition.
\expand:after #1->\def \e:tmp
{#1}\expandafter \e:tmp
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! Use of \def doesn't match its definition.
\adv:c #1->\bgroup \def \:temp
{#1}\tmp:cnt #1\afterassignment \:gplus \mth:...
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! Use of \let doesn't match its definition.
\Protect ->\let \prOteCt
\pr:tc \ifx \prOteCt \pr:tc \let \prOteCt \relax \e...
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! Use of \let doesn't match its definition.
\Protect ->\let \prOteCt
\pr:tc \ifx \prOteCt \pr:tc \let \prOteCt \relax \e...
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! Missing number, treated as zero.
<to be read again>
}
l.11 \printif{apple\footnotemark[1]}{orange}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Use of \def doesn't match its definition.
\adv:c #1->\bgroup \def \:temp
{#1}\tmp:cnt #1\afterassignment \:gplus \mth:...
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! Missing number, treated as zero.
<to be read again>
\xdef
l.11 \printif{apple\footnotemark[1]}{orange}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Missing control sequence inserted.
<inserted text>
\inaccessible
l.11 \printif{apple\footnotemark[1]}{orange}
Please don't say `\def cs{...}', say `\def\cs{...}'.
I've inserted an inaccessible control sequence so that your
definition will be completed without mixing me up too badly.
You can recover graciously from this error, if you're
careful; see exercise 27.2 in The TeXbook.
! Use of \def doesn't match its definition.
\:aplus ->\xdef \:temp {\def \expandafter
\noexpand \:temp {\the \tmp:cnt }}...
l.11 \printif{apple\footnotemark[1]}{orange}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
! Too many }'s.
\:aplus ...expand \:temp {\the \tmp:cnt }}\egroup
\:temp
l.11 \printif{apple\footnotemark[1]}{orange}
You've closed more groups than you opened.
Such booboos are generally harmless, so keep going.
! TeX capacity exceeded, sorry [input stack size=5000].
\:temp ->\:temp
{0}
l.11 \printif{apple\footnotemark[1]}{orange}
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.
No pages of output.
mwe.cfg
\Preamble{xhtml,fn-in}
\begin{document}
\EndPreamble