English correspondence of words in the Russian text

I have a multilingual TeX document, mostly in Russian, but I also include some English terms in brackets to make the reader familiar with international terminology. For example, the phrase

Two integral properties of a programming language are syntax (syntax) and semantics (semantics).

which just means

Two attributes of programming a language are its syntax and semantics.

looks like

Two integral properties of a programming language are \ Textit {} syntax (\ Textit {\ selectlanguage {} English syntax \ selectlanguage {Russian}}) and \ textit {semantics} (\ Textit {\ selectlanguage {English} semantics \ selectlanguage {Russian }}).

I also have \ usepackage [english, russian] {babel}.

The code looks too detailed, because I need to use the \ selectlanguage language on every English word twice to make a hyphen. Without this I get a couple

Overfull \ hbox ...

because TeX cannot hyphens English words when they appear at the ends of lines.

Is there a better solution?


In response to Alexei Malistov.

MacTeX distribution has several language.dat files

  • / Usr / local / texlive / 2009 / texmf-distribution / source / general / pandemonium
  • / Usr / local / texlive / 2009 / texmf-distribution / doc / general / pandemonium
  • / Usr / local / texlive / 2009 / texmf / tex / general / configuration
  • / Usr / local / texlive / 2009 / texmf-var / tex / general / configuration
  • / Usr / local / texlive / 2009 / texmf-distribution / tex / lambda / configuration

I'm not sure which one I should edit. Probably one of the first two. They are identical

% File : language.dat % Purpose : specify which hypenation patterns to load % while running iniTeX =USenglish american ushyphen.tex =english UKenglish ukhyphen.tex =british french frhyphen.tex dutch nehyph2.tex german dehypht.tex ngerman dehyphn.tex 

But which one?

Also there is no initexmf command. Going to the search, I found out that the analog is updmap-sys. But I'm not sure ... I'm afraid to ruin my TeX installation. Please give me the right direction.

+4
source share
4 answers

Instead of using \selectlanguage{} twice because it is a switch, you can use either the otherlanguage environment or the \foreighlanguage macro:

 \begin{otherlanguage}{english} Hello world \end{otherlanguage} 

Or, for inline changes, as in your example:

      --- \emph{} (\foreignlanguage{english}{\emph{syntax}})  \emph{} (\foreignlanguage{english}{\emph{semantics}}). 

In fact, if you often give English terms, you can define a macro:

 \newcommand{\englishterm}[1]{% \foreignlanguage{english}{\emph{#1}}} 
+1
source

You must combine English and Russian hyphens. Modify the language.dat file to add the following:

 ruseng ruenhyph =russian =english 

And recompile all format files:

 initexmf --dump 

Add

I am using MikTeX. I do not know what you should do for sure. I would try to experiment.

  • You should add a “new ruseng language” which contains English and Russian hypnas. Then the macro \setlanguage not required. It works very well for me. I use Russian and English words and do not use \setlanguage .

  • You must recompile the file formats. MikTeX provides the initexmf command. I am sure there is a similar command for your MacTeX.

+2
source

You can add discretionary hyphens ( \- ) to each English word, if necessary.

Alternatively, you can define your own environment that handles both textit and language selection.

+1
source

I believe that \selectlanguage should follow the usual scope rules so that you can enclose the part you want in English in braces that limit the local scope:

      --- \textit{} ({\textit{\selectlanguage{english}syntax}})  \textit{} ({\textit{\selectlanguage{english}semantics}}). 

I can’t check it right now, so if you find that this doesn’t work, I would be glad if you would let me know so that I can change or delete this answer.

+1
source

Source: https://habr.com/ru/post/1300560/


All Articles