Problem with nested if statements
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I'm trying to use some nested if
statements to decide if a file exists and what kind of loadings are possible:
IfFileExists./emoji.sty
ifxetex
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
else
usepackageifluatex
ifluatex
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
else
usepackage[bw]emoji
fi
fi
newcommanddoxygenemoji[3]
IfFileExistsbw/#3.png
emoji#3
#1
renewcommanddoxygenemoji[3] #1
but unfortunately I get the error message:
! Extra else.
IfFileExists ...ileonpath #1#2#3}fi else
closein @inputcheck ede...
l.60 }
where line 60 is the last closing bracket (}
).
(Not yet a real MWE but hopefully I can get some hints already).
conditionals nesting ifthenelse
add a comment |Â
up vote
2
down vote
favorite
I'm trying to use some nested if
statements to decide if a file exists and what kind of loadings are possible:
IfFileExists./emoji.sty
ifxetex
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
else
usepackageifluatex
ifluatex
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
else
usepackage[bw]emoji
fi
fi
newcommanddoxygenemoji[3]
IfFileExistsbw/#3.png
emoji#3
#1
renewcommanddoxygenemoji[3] #1
but unfortunately I get the error message:
! Extra else.
IfFileExists ...ileonpath #1#2#3}fi else
closein @inputcheck ede...
l.60 }
where line 60 is the last closing bracket (}
).
(Not yet a real MWE but hopefully I can get some hints already).
conditionals nesting ifthenelse
1
Loadifluatex
before startingIfFileExists
; otherwiseifluatex
is not a conditional unless you are usingluatex
and therefore a missing conditional error ensues.
â egreg
1 hour ago
@egreg, but one still needs the double##
, correct?
â albert
1 hour ago
Yes, I was explaining the âÂÂapparently doesn't like theifluatex
conditionalâ in Phelype's answer. By the way, you have several spurious spaces in your code.
â egreg
1 hour ago
the ones with the renewcommand (should be newcommand) around the#1
are known. Which others?
â albert
1 hour ago
@egreg Ooh, that explains the problem with the conditional. Same problem as in my question aboutdocstrip
a few weeks ago. I'm a slow learner :P
â Phelype Oleinik
1 hour ago
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm trying to use some nested if
statements to decide if a file exists and what kind of loadings are possible:
IfFileExists./emoji.sty
ifxetex
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
else
usepackageifluatex
ifluatex
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
else
usepackage[bw]emoji
fi
fi
newcommanddoxygenemoji[3]
IfFileExistsbw/#3.png
emoji#3
#1
renewcommanddoxygenemoji[3] #1
but unfortunately I get the error message:
! Extra else.
IfFileExists ...ileonpath #1#2#3}fi else
closein @inputcheck ede...
l.60 }
where line 60 is the last closing bracket (}
).
(Not yet a real MWE but hopefully I can get some hints already).
conditionals nesting ifthenelse
I'm trying to use some nested if
statements to decide if a file exists and what kind of loadings are possible:
IfFileExists./emoji.sty
ifxetex
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
else
usepackageifluatex
ifluatex
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
else
usepackage[bw]emoji
fi
fi
newcommanddoxygenemoji[3]
IfFileExistsbw/#3.png
emoji#3
#1
renewcommanddoxygenemoji[3] #1
but unfortunately I get the error message:
! Extra else.
IfFileExists ...ileonpath #1#2#3}fi else
closein @inputcheck ede...
l.60 }
where line 60 is the last closing bracket (}
).
(Not yet a real MWE but hopefully I can get some hints already).
conditionals nesting ifthenelse
conditionals nesting ifthenelse
edited 1 hour ago
Phelype Oleinik
17.3k43770
17.3k43770
asked 2 hours ago
albert
450314
450314
1
Loadifluatex
before startingIfFileExists
; otherwiseifluatex
is not a conditional unless you are usingluatex
and therefore a missing conditional error ensues.
â egreg
1 hour ago
@egreg, but one still needs the double##
, correct?
â albert
1 hour ago
Yes, I was explaining the âÂÂapparently doesn't like theifluatex
conditionalâ in Phelype's answer. By the way, you have several spurious spaces in your code.
â egreg
1 hour ago
the ones with the renewcommand (should be newcommand) around the#1
are known. Which others?
â albert
1 hour ago
@egreg Ooh, that explains the problem with the conditional. Same problem as in my question aboutdocstrip
a few weeks ago. I'm a slow learner :P
â Phelype Oleinik
1 hour ago
add a comment |Â
1
Loadifluatex
before startingIfFileExists
; otherwiseifluatex
is not a conditional unless you are usingluatex
and therefore a missing conditional error ensues.
â egreg
1 hour ago
@egreg, but one still needs the double##
, correct?
â albert
1 hour ago
Yes, I was explaining the âÂÂapparently doesn't like theifluatex
conditionalâ in Phelype's answer. By the way, you have several spurious spaces in your code.
â egreg
1 hour ago
the ones with the renewcommand (should be newcommand) around the#1
are known. Which others?
â albert
1 hour ago
@egreg Ooh, that explains the problem with the conditional. Same problem as in my question aboutdocstrip
a few weeks ago. I'm a slow learner :P
â Phelype Oleinik
1 hour ago
1
1
Load
ifluatex
before starting IfFileExists
; otherwise ifluatex
is not a conditional unless you are using luatex
and therefore a missing conditional error ensues.â egreg
1 hour ago
Load
ifluatex
before starting IfFileExists
; otherwise ifluatex
is not a conditional unless you are using luatex
and therefore a missing conditional error ensues.â egreg
1 hour ago
@egreg, but one still needs the double
##
, correct?â albert
1 hour ago
@egreg, but one still needs the double
##
, correct?â albert
1 hour ago
Yes, I was explaining the âÂÂapparently doesn't like the
ifluatex
conditionalâ in Phelype's answer. By the way, you have several spurious spaces in your code.â egreg
1 hour ago
Yes, I was explaining the âÂÂapparently doesn't like the
ifluatex
conditionalâ in Phelype's answer. By the way, you have several spurious spaces in your code.â egreg
1 hour ago
the ones with the renewcommand (should be newcommand) around the
#1
are known. Which others?â albert
1 hour ago
the ones with the renewcommand (should be newcommand) around the
#1
are known. Which others?â albert
1 hour ago
@egreg Ooh, that explains the problem with the conditional. Same problem as in my question about
docstrip
a few weeks ago. I'm a slow learner :Pâ Phelype Oleinik
1 hour ago
@egreg Ooh, that explains the problem with the conditional. Same problem as in my question about
docstrip
a few weeks ago. I'm a slow learner :Pâ Phelype Oleinik
1 hour ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
You need to double the parameter characters because IfFileExists
grabs the true and false branch as arguments. Also, it apparently doesn't like the ifluatex
conditional. You can use iftex
's conditionals:
usepackageiftex
IfFileExists./emoji.sty
ifXeTeX
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
else
ifLuaTeX
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
else
usepackage[bw]emoji
fi
fi
newcommanddoxygenemoji[3]
IfFileExistsbw/##3.png
emoji##3
##1
newcommanddoxygenemoji[3] ##1
Or, to avoid doubling the parameter characters and for an extra degree of robustness you can use expl3
's conditionals:
usepackageexpl3
ExplSyntaxOn
file_if_exist:nTF ./emoji.sty
sys_if_engine_xetex:T
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
sys_if_engine_luatex:T
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
sys_if_engine_pdftex:T
usepackage[bw]emoji
cs_new:Npn doxygenemoji #1 #2 #3
file_if_exist:nTF bw/#3.png
emoji #3
#1
cs_new:Npn doxygenemoji #1 #2 #3
##1
ExplSyntaxOff
add a comment |Â
up vote
2
down vote
There are two errors in your code. The first is loading ifluatex
inside a conditional; if the code is skipped (because the engine is XeLaTeX), ifluatex
will not yet be a conditional, but an undefined token, resulting in an unbalanced conditional.
The second error is not doubling #
in the definition.
I'd reorganize the code in a different fashion, avoiding complicated code in the true and false branches of IfFileExists
.
usepackageifluatex,ifxetex
newififemoji
IfFileExists./emoji.styemojitrueemojifalse
ifemoji
ifxetex
usepackagefontspec
PassOptionsToPackagefont=seguiemj.ttfemoji
fi
ifluatex
usepackagefontspec
PassOptionsToPackagefont=Symbola_hint.ttfemoji
fi
usepackage[bw]emoji
newcommanddoxygenemoji[3]%
IfFileExistsbw/#3.png%
emoji#3%
%
#1%
%
else
newcommanddoxygenemoji[3]#1
fi
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You need to double the parameter characters because IfFileExists
grabs the true and false branch as arguments. Also, it apparently doesn't like the ifluatex
conditional. You can use iftex
's conditionals:
usepackageiftex
IfFileExists./emoji.sty
ifXeTeX
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
else
ifLuaTeX
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
else
usepackage[bw]emoji
fi
fi
newcommanddoxygenemoji[3]
IfFileExistsbw/##3.png
emoji##3
##1
newcommanddoxygenemoji[3] ##1
Or, to avoid doubling the parameter characters and for an extra degree of robustness you can use expl3
's conditionals:
usepackageexpl3
ExplSyntaxOn
file_if_exist:nTF ./emoji.sty
sys_if_engine_xetex:T
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
sys_if_engine_luatex:T
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
sys_if_engine_pdftex:T
usepackage[bw]emoji
cs_new:Npn doxygenemoji #1 #2 #3
file_if_exist:nTF bw/#3.png
emoji #3
#1
cs_new:Npn doxygenemoji #1 #2 #3
##1
ExplSyntaxOff
add a comment |Â
up vote
3
down vote
accepted
You need to double the parameter characters because IfFileExists
grabs the true and false branch as arguments. Also, it apparently doesn't like the ifluatex
conditional. You can use iftex
's conditionals:
usepackageiftex
IfFileExists./emoji.sty
ifXeTeX
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
else
ifLuaTeX
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
else
usepackage[bw]emoji
fi
fi
newcommanddoxygenemoji[3]
IfFileExistsbw/##3.png
emoji##3
##1
newcommanddoxygenemoji[3] ##1
Or, to avoid doubling the parameter characters and for an extra degree of robustness you can use expl3
's conditionals:
usepackageexpl3
ExplSyntaxOn
file_if_exist:nTF ./emoji.sty
sys_if_engine_xetex:T
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
sys_if_engine_luatex:T
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
sys_if_engine_pdftex:T
usepackage[bw]emoji
cs_new:Npn doxygenemoji #1 #2 #3
file_if_exist:nTF bw/#3.png
emoji #3
#1
cs_new:Npn doxygenemoji #1 #2 #3
##1
ExplSyntaxOff
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You need to double the parameter characters because IfFileExists
grabs the true and false branch as arguments. Also, it apparently doesn't like the ifluatex
conditional. You can use iftex
's conditionals:
usepackageiftex
IfFileExists./emoji.sty
ifXeTeX
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
else
ifLuaTeX
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
else
usepackage[bw]emoji
fi
fi
newcommanddoxygenemoji[3]
IfFileExistsbw/##3.png
emoji##3
##1
newcommanddoxygenemoji[3] ##1
Or, to avoid doubling the parameter characters and for an extra degree of robustness you can use expl3
's conditionals:
usepackageexpl3
ExplSyntaxOn
file_if_exist:nTF ./emoji.sty
sys_if_engine_xetex:T
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
sys_if_engine_luatex:T
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
sys_if_engine_pdftex:T
usepackage[bw]emoji
cs_new:Npn doxygenemoji #1 #2 #3
file_if_exist:nTF bw/#3.png
emoji #3
#1
cs_new:Npn doxygenemoji #1 #2 #3
##1
ExplSyntaxOff
You need to double the parameter characters because IfFileExists
grabs the true and false branch as arguments. Also, it apparently doesn't like the ifluatex
conditional. You can use iftex
's conditionals:
usepackageiftex
IfFileExists./emoji.sty
ifXeTeX
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
else
ifLuaTeX
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
else
usepackage[bw]emoji
fi
fi
newcommanddoxygenemoji[3]
IfFileExistsbw/##3.png
emoji##3
##1
newcommanddoxygenemoji[3] ##1
Or, to avoid doubling the parameter characters and for an extra degree of robustness you can use expl3
's conditionals:
usepackageexpl3
ExplSyntaxOn
file_if_exist:nTF ./emoji.sty
sys_if_engine_xetex:T
usepackage[bw,font=seguiemj.ttf]emoji
usepackagefontspec
sys_if_engine_luatex:T
usepackage[bw,font=Symbola_hint.ttf]emoji
usepackagefontspec
sys_if_engine_pdftex:T
usepackage[bw]emoji
cs_new:Npn doxygenemoji #1 #2 #3
file_if_exist:nTF bw/#3.png
emoji #3
#1
cs_new:Npn doxygenemoji #1 #2 #3
##1
ExplSyntaxOff
answered 1 hour ago
Phelype Oleinik
17.3k43770
17.3k43770
add a comment |Â
add a comment |Â
up vote
2
down vote
There are two errors in your code. The first is loading ifluatex
inside a conditional; if the code is skipped (because the engine is XeLaTeX), ifluatex
will not yet be a conditional, but an undefined token, resulting in an unbalanced conditional.
The second error is not doubling #
in the definition.
I'd reorganize the code in a different fashion, avoiding complicated code in the true and false branches of IfFileExists
.
usepackageifluatex,ifxetex
newififemoji
IfFileExists./emoji.styemojitrueemojifalse
ifemoji
ifxetex
usepackagefontspec
PassOptionsToPackagefont=seguiemj.ttfemoji
fi
ifluatex
usepackagefontspec
PassOptionsToPackagefont=Symbola_hint.ttfemoji
fi
usepackage[bw]emoji
newcommanddoxygenemoji[3]%
IfFileExistsbw/#3.png%
emoji#3%
%
#1%
%
else
newcommanddoxygenemoji[3]#1
fi
add a comment |Â
up vote
2
down vote
There are two errors in your code. The first is loading ifluatex
inside a conditional; if the code is skipped (because the engine is XeLaTeX), ifluatex
will not yet be a conditional, but an undefined token, resulting in an unbalanced conditional.
The second error is not doubling #
in the definition.
I'd reorganize the code in a different fashion, avoiding complicated code in the true and false branches of IfFileExists
.
usepackageifluatex,ifxetex
newififemoji
IfFileExists./emoji.styemojitrueemojifalse
ifemoji
ifxetex
usepackagefontspec
PassOptionsToPackagefont=seguiemj.ttfemoji
fi
ifluatex
usepackagefontspec
PassOptionsToPackagefont=Symbola_hint.ttfemoji
fi
usepackage[bw]emoji
newcommanddoxygenemoji[3]%
IfFileExistsbw/#3.png%
emoji#3%
%
#1%
%
else
newcommanddoxygenemoji[3]#1
fi
add a comment |Â
up vote
2
down vote
up vote
2
down vote
There are two errors in your code. The first is loading ifluatex
inside a conditional; if the code is skipped (because the engine is XeLaTeX), ifluatex
will not yet be a conditional, but an undefined token, resulting in an unbalanced conditional.
The second error is not doubling #
in the definition.
I'd reorganize the code in a different fashion, avoiding complicated code in the true and false branches of IfFileExists
.
usepackageifluatex,ifxetex
newififemoji
IfFileExists./emoji.styemojitrueemojifalse
ifemoji
ifxetex
usepackagefontspec
PassOptionsToPackagefont=seguiemj.ttfemoji
fi
ifluatex
usepackagefontspec
PassOptionsToPackagefont=Symbola_hint.ttfemoji
fi
usepackage[bw]emoji
newcommanddoxygenemoji[3]%
IfFileExistsbw/#3.png%
emoji#3%
%
#1%
%
else
newcommanddoxygenemoji[3]#1
fi
There are two errors in your code. The first is loading ifluatex
inside a conditional; if the code is skipped (because the engine is XeLaTeX), ifluatex
will not yet be a conditional, but an undefined token, resulting in an unbalanced conditional.
The second error is not doubling #
in the definition.
I'd reorganize the code in a different fashion, avoiding complicated code in the true and false branches of IfFileExists
.
usepackageifluatex,ifxetex
newififemoji
IfFileExists./emoji.styemojitrueemojifalse
ifemoji
ifxetex
usepackagefontspec
PassOptionsToPackagefont=seguiemj.ttfemoji
fi
ifluatex
usepackagefontspec
PassOptionsToPackagefont=Symbola_hint.ttfemoji
fi
usepackage[bw]emoji
newcommanddoxygenemoji[3]%
IfFileExistsbw/#3.png%
emoji#3%
%
#1%
%
else
newcommanddoxygenemoji[3]#1
fi
answered 1 hour ago
egreg
685k8418273077
685k8418273077
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f452938%2fproblem-with-nested-if-statements%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Load
ifluatex
before startingIfFileExists
; otherwiseifluatex
is not a conditional unless you are usingluatex
and therefore a missing conditional error ensues.â egreg
1 hour ago
@egreg, but one still needs the double
##
, correct?â albert
1 hour ago
Yes, I was explaining the âÂÂapparently doesn't like the
ifluatex
conditionalâ in Phelype's answer. By the way, you have several spurious spaces in your code.â egreg
1 hour ago
the ones with the renewcommand (should be newcommand) around the
#1
are known. Which others?â albert
1 hour ago
@egreg Ooh, that explains the problem with the conditional. Same problem as in my question about
docstrip
a few weeks ago. I'm a slow learner :Pâ Phelype Oleinik
1 hour ago