I have an English article in LaTeX, which I'm going to translate to Russian. I want to keep my translation in sync with the original text. It means that I want every paragraph to stay as close to its original version as possible. Ideally like this:

\UseLanguage{English} % or Russian
The technology described in the article is very complex.
  \inRussian{Технология, описанная в статье, очень сложна.}

The preamble will specify which language to use and the document will be automatically compiled for this selected language. Is there any packages that will enable me to translate the article in such a way?


6 Answers 6


Define two macros, and swap their definitions as needed



or define one macro


and change #1 to #2 when you want to switch language.

  • 2
    I really like this solution except for one bit: You have to change the source file and then re-run latex to produce two files. Is it possible to use a environment variable or something? So one could run "LATEX_LANG=en pdflatex foo.tex" to output foo_en.pdf?
    – user3819
    Commented Feb 26, 2011 at 6:55
  • 4
    A solution to this can be found here: latex-community.org/forum/…
    – user3819
    Commented Feb 26, 2011 at 7:17

I'd usually convert the LaTeX file to a PO file (using po2a) and use a dedicated translation tool like Virtaal, Russian LaTeX file can then be generated from the translated PO file. Later when the English is changed the translation can easily synced using standard PO merging tools. Well, it sounds too complicated but it is fairly scalable, besides I do things like that nearly daily, so that is my natural choice.

  • I have just came accross this thread and this is wonderful and clean solution
    – Zbynek
    Commented Jan 19, 2015 at 8:53
  • I love this solution but the po4a gettextize extracts also many formatting details. For example if there is a table, it extracts the entire blueprint of the table. Is there any way to help po4a extract only translatable strings? For example by surrounding them by some special command e.g. \tr{This string is to be translated.} Commented Jan 24, 2015 at 19:14

You can use the comment package for this and define environments for each language. This supports longer text parts and might be more efficient as a macro.

% (still needs font and input encoding for Russian text)
% change that the other way around to activate Russian language:

The technology described in the article is very complex.
Технология, описанная в статье, очень сложна.

Note that this seems not to work inside the documentation text of a DTX file, most likely because of the changed catcode of %. But this isn't relevant for normal documents like yours.

  • Nice and clean solution but using the comment package seems also not to work when wanting to define different captions in a tabularx environment, for example, because such additional control sequences seem to be forbidden. The \if approach of Charles works better in this case.
    – der Michi
    Commented Aug 29, 2019 at 10:04

My answer has the same basic idea as Boris' answer, but uses tex's \if syntax, which to my taste gives cleaner source:

\englishtrue % Show English text only
%\englishfalse will show Russian text only
  The technology described in the article is very complex.
  Технология, описанная в статье, очень сложна.

Khaled's approach, using localisation, is the proper way to do it. XLIFF is a pretty widely used XML format; see XML in localisation: A practical analysis.

  • +1, I'm using this at the moment in a DTX file of mine, because the comment package (see my answer) doesn't work for that. Commented Jan 31, 2011 at 18:12

I know this question has already been answered, but I wanted to share my two cents.

I was searching for the same exact thing as yegor256, and starting from the pointers in other answers I put together a small sty file that fits my needs. It supports an arbitrary number of different languages in the same document.

% Environment settings



% Multilingual support commands
    \ifthenelse{\equal{#1}{\doclang} \or \equal{#1}{\doclangshort}}

It's useful because it synchronizes also the correct language for the babel package, such that your document will always have the correct locale settings. You just have to write a code like this in your tex:

\usepackage[italian,english]{babel} %enables babel to every lang supported by your document
\usepackage{multilanguage} % import the file with the above definitions
\setdoclang{it}{italian} % set short and long language codes
                         % the second one must be known by babel

After that you can mix in your regular document parts that shows up in every language (i.e. document structure, images, ...) and parts that shows up only for certain languages, like this:

% Sections, subsections, subsubsections:
\sectionlang{it}{Sezione 1} % in the first parameter you can freely use
                            % both short or long language codes
\sectionlang{english}{Section 1}

% Strings that are displayed only in a certain language
\lang{it}{Questa stringa appare solo in italiano.}
\lang{en}{This string shows up only in English.}

% When you have only two languages, you can simply rely on this if-else
% construct
\langif{it}{If vero: questo e' italiano.}{Else: this is for any language
different from Italian.}

Suggestion to the old version of the question:

Perhaps either parallel or parcolumns can be helpful.

Suggestion to the new version of the question:

You could use the language of the document as some kind of switch. Here is an example from my archives.


\let\langname\languagename      % It doesn't work without this line

    Russian                     % Put all necessary stuff for the Russian version here
    English                     % Put all necessary stuff for the English version here

The language option for babel (here put into the options for the document class) controls which version of the document is compiled. Other helpful suggestions may come from the TeX FAQ.

  • Maybe I didn't explain it properly, I want my document to be in only one language, which I will select in preamble
    – yegor256
    Commented Nov 8, 2010 at 9:44

You must log in to answer this question.

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