I'm creating a mystyle.sty
package that sets backgrounds, styles and an introduction. The main .tex file only contains few package loading and options, and of course the main text. One of the options is
\setdefaultlanguage{finnish}
What I need is that the introduction part (in the package) would change to e.g. english should I change the default language to english too. So the question is:
- If possible, how do I detect the language that is set by the command
\setdefaultlanguage
? - Which would be the simplest way to use this information to choose the appropriate intro?
For the second question, the introtext commands are stored to, say, \introinfinnish
and \introinenglish
. Number of different languages are not restricted to two.
A minimal XeLaTeX example (main.tex
):
\documentclass[12pt,a4paper]{memoir}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{finnish} % (english)
\setotherlanguage{english}
\usepackage{mystyle}
\begin{document}
\intropage % from mystyle
\clearpage
Something in finnish % (english)
\end{document}
and the package (mystyle.sty
)
\ProvidesPackage{mystyle}
\newcommand{\introinfinnish}{Text in finnish...}
\newcommand{\introinenglish}{Text in english...}
% some commands that selects the correct introtext and stores it into \introtext
\newcommand{\intropage}{ % just a sketch
\@date
\vfill
\introtext
}
Best Answer
The main language is stored in
\xpg@main@language
, so something like the following will do.As you see, you can use any language you wish, provided you give a definition fo
\introin<language>
.Please, use
\setmainlanguage
rather than the deprecated\setdefaultlanguage