TeX - LaTeX Asked on February 19, 2021
My problem is quite simple. I use the babel package and depending on the language I want to display something with respect to the active language. Therefore I use the package xstring
. My code is the following
documentclass[10pt]{article}
usepackage{xstring}
usepackage[french,english]{babel}
begin{document}
selectlanguage{french}
languagename%show the string
IfStrEq{languagename}{french}{Yes, it's french!}{No, it's not french!}
end{document}
This does not work. Anyone an idea?
Thanks in advance.
Finally I found that using
iflanguage{english}{this is english}
iflanguage{french}{this is french}
is far more simple without using the xstring package.
Answered by Willi on February 19, 2021
You have to use IfStrEq*
, because the string returned by languagename
consists of category code 12 characters.
documentclass[10pt]{article}
usepackage{xstring}
usepackage[french,english]{babel}
begin{document}
languagename%show the string
IfStrEq*{languagename}{french}{Yes, it's french!}{No, it's not french!}
selectlanguage{french}
languagename%show the string
IfStrEq*{languagename}{french}{Yes, it's french!}{No, it's not french!}
end{document}
Answered by egreg on February 19, 2021
The minimal example with the iflang solution of Javier Bezos would be:
documentclass[10pt]{article}
usepackage{iflang}
usepackage[french,english]{babel}
begin{document}
title{%
IfLanguageName{french}{Yes, it's french!}{No, it's not french!}%
selectlanguage{french}%
IfLanguageName{french}{Yes, it's french!}{No, it's not french!}%
}
end{document}
Answered by Scotty on February 19, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP