Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am writing a book in two languages: a Russian version and an English version. Is it possible to do this in the same file?

Something like \tltext{Hello world!}{Здравствуй, мир!}, and mark at the start of the preamble which variant is needed.

The idea is that if I needed to change something, I wouldn't have to do it in both files.

share|improve this question
4  
    
This appears to be a near duplicate of the following question: Whether it's possible to keep translation together with original text?. If the answers there help you, we can close this question. –  Alan Munn Jun 5 '11 at 22:29
    
Sorry. I didn't find it. –  newuser Jun 6 '11 at 7:13
add comment

migrated from stackoverflow.com Jun 5 '11 at 22:17

This question came from our site for professional and enthusiast programmers.

2 Answers

babel provides \iflanguage, but its usage for large parts of text is cumbersome.

\documentclass{book}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}

\newif\ifenglish
\newcommand{\chooselanguage}[1]{%
  \selectlanguage{#1}%
  \iflanguage{english}{\englishtrue}{\englishfalse}}

\begin{document}
\chooselanguage{english}
%\chooselanguage{russian}

\ifenglish
  Hello world!
\else
  Здраствуй мир!
\fi

\ifenglish
  Thank you
\else
  Спасибо
\fi

\end{document}

In other words, you write each paragraph (or part of text in general) putting between \ifenglish and \else the English version, and between \else and \fi the Russian text.

You choose the language by commenting or uncommenting the lines after \begin{document}.

share|improve this answer
add comment

This might just work, simply comment out the version that you don't want. You might eventually want to choose a shorter name than \tltext for the command because you're going to be typing it many, many times if you're writing a book.

\documentclass{article}

\newcommand{\tltext}[2]{#1}% use English version
%\newcommand{\tltext}[2]{#2}% use Russian version

\begin{document}
\tltext{Hello world!}{Здраствуй мир!}
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.