Generating multiple versions of a document using options
up vote
17
down vote
favorite
Before I start, I want to say that I have already read this post and this post
I am writing a paper in two languages. I want to write other language version of every paragraphs and title just below the original version.
Is the any two switch two language by using same options like
Lang == Esp
if{Lang=Eng}
chapter{LITERATURE}
elif
chapter{LITERATURA}
or
if{Lang=Eng}
{I love you.}
elif
{Te quiero.}
Is there any way to do that?
conditionals languages
add a comment |
up vote
17
down vote
favorite
Before I start, I want to say that I have already read this post and this post
I am writing a paper in two languages. I want to write other language version of every paragraphs and title just below the original version.
Is the any two switch two language by using same options like
Lang == Esp
if{Lang=Eng}
chapter{LITERATURE}
elif
chapter{LITERATURA}
or
if{Lang=Eng}
{I love you.}
elif
{Te quiero.}
Is there any way to do that?
conditionals languages
add a comment |
up vote
17
down vote
favorite
up vote
17
down vote
favorite
Before I start, I want to say that I have already read this post and this post
I am writing a paper in two languages. I want to write other language version of every paragraphs and title just below the original version.
Is the any two switch two language by using same options like
Lang == Esp
if{Lang=Eng}
chapter{LITERATURE}
elif
chapter{LITERATURA}
or
if{Lang=Eng}
{I love you.}
elif
{Te quiero.}
Is there any way to do that?
conditionals languages
Before I start, I want to say that I have already read this post and this post
I am writing a paper in two languages. I want to write other language version of every paragraphs and title just below the original version.
Is the any two switch two language by using same options like
Lang == Esp
if{Lang=Eng}
chapter{LITERATURE}
elif
chapter{LITERATURA}
or
if{Lang=Eng}
{I love you.}
elif
{Te quiero.}
Is there any way to do that?
conditionals languages
conditionals languages
edited Nov 27 at 12:05
Phelype Oleinik
21.2k54380
21.2k54380
asked Nov 27 at 10:14
i2_
954
954
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
up vote
13
down vote
accepted
You could use an approach like the following, I use it to create various versions of a CV document.
documentclass{minimal}
usepackage{ifthen}
newboolean{somevariable}
setboolean{somevariable}{false}
begin{document}
ifthenelse{boolean{somevariable}}{Text if somevariable is true.}{Text if somevariable is false.}
end{document}
Works smoothly. This is what i need it. Thank you!!!
– i2_
Nov 27 at 11:43
1
Then please tag my answer as the solution. It helps other to find it more easily.
– Uwe Ziegenhagen
Nov 27 at 15:41
add a comment |
up vote
15
down vote
There's always docstrip
, which lets you distinguish one code from another using special comments (called guards) and also have code which is common to both.
In my opinion, the advantage of this method over the conditionals is that it's fairly simple to add more languages avoiding the hassle of nesting conditionals.
For instance, you can have a source file (let's call it source.dtx
, but any other name will do):
documentclass{book}
begin{document}
%<english>chapter{LITERATURE}
%<spanish>chapter{LITERATURA}
%<*english>
emph{The Tau Manifesto} is dedicated to one of the most important numbers in
mathematics, perhaps emph{the} most important: the emph{circle constant} relating
the circumference of a circle to its linear dimension. For millennia, the circle has
been considered the most perfect of shapes, and the circle constant captures the
geometry of the circle in a single number. Of course, the traditional choice for
the circle constant is $pi$--but, as mathematician Bob Palais notes in his
delightful article ``$pi$ Is Wrong!'', $pi$ emph{is wrong}. It's time to set
things right.
%</english>
%<*spanish>
emph{El Manifiesto de Tau} está dedicado a uno de los números más importantes en
matemáticas, quizás emph{el} más importante: la emph{constante de círculo} que relaciona
la circunferencia de un círculo con su dimensión lineal. Durante milenios, el círculo ha
sido considerado la forma más perfecta, y la constante del círculo captura la
geometría del círculo en un solo número. Por supuesto, la elección tradicional para
la constante de círculo es $pi$--pero, como señala el matemático Bob Palais en su
artículo encantador ``$pi$ Is Wrong!'', $Pi$ emph{es incorrecto}. Es hora de arreglar las cosas.
%</spanish>
end{document}
(sample text taken from here and Google-Translated to Spanish)
then you only need a so-called “installation file”:
input docstrip % Loads the docstrip program
% Optional switches
askforoverwritefalse % Allows it to overwrite older files without asking
keepsilent % Reduces verbosity
nopreamble % Removes preamble
nopostamble % removes postamble
% Separating sources:
generate{%
%
file{english.tex}{%
from{source.dtx}{english}%
}%
%
file{spanish.tex}{%
from{source.dtx}{spanish}%
}%
%
}
% Exiting
endbatchfile
which will generate an english.tex
file from the parts that are marked as <english>
in the source.dtx
and another one called spanish.tex
from the parts marked with <spanish>
in the source.dtx
. The parts of the source.dtx
which aren't marked go to both output files.
To execute this you only need to run TeX on the installation file:
> pdftex installation.ins
The generated english.tex
will look like this:
documentclass{book}
begin{document}
chapter{LITERATURE}
emph{The Tau Manifesto} is dedicated to one of the most important numbers in
mathematics, perhaps emph{the} most important: the emph{circle constant} relating
the circumference of a circle to its linear dimension. For millennia, the circle has
been considered the most perfect of shapes, and the circle constant captures the
geometry of the circle in a single number. Of course, the traditional choice for
the circle constant is $pi$--but, as mathematician Bob Palais notes in his
delightful article ``$pi$ Is Wrong!'', $pi$ emph{is wrong}. It's time to set
things right.
end{document}
This solution also works and as you said we definitely work on cleaner source tex. But in this case i do not want to create new files. Thank you anyway!
– i2_
Nov 27 at 12:26
2
@i2_ I'm afraid there's no way to usedocstrip
without generating other source files. In fact, this is the purpose ofdocstrip
: to generate usable TeX code from one (or more) source files. But, if you can live with the multiple files (why, not; LaTeX creates a bunch of them anyway :-), since this operates “outside” the TeX run of your document, you don't have to worry about verbatim content being messed up, and you can do some other tricks which aren't possible when you need to keep braces and groups balanced. Pros and cons of each method :)
– Phelype Oleinik
Nov 27 at 12:48
add a comment |
up vote
11
down vote
You can use the iflang package:
documentclass{article}
usepackage[english,ngerman]{babel}
usepackage{iflang}
begin{document}
IfLanguageName{english}{This is english}{This is not english}
IfLanguageName{ngerman}{Das ist deutsch}{Das ist nicht deutsch}
selectlanguage{english}
IfLanguageName{english}{This is english}{This not english}
IfLanguageName{ngerman}{Das ist deutsch}{Das ist nicht deutsch}
end{document}
add a comment |
up vote
7
down vote
The comment
package makes it easy to define arbitrary throw-away environments:
documentclass{article}
usepackage{comment}
% define comment sections that are either included or excluded
excludecomment{ENG}
includecomment{GER}
begin{document}
begin{ENG}
In the beginning was the Word, and the Word was with God, and the Word was God.
end{ENG}
begin{GER}
Am Anfang war das Wort und das Wort war bei Gott und Gott war das Wort.
end{GER}
end{document}
If one defines both environments with includecomment
, both will become part of the output.
Technically, this comes close to the docstrip
approach suggested by Phelype Oleinik as the excluded sections are actually gobbled (lexically thrown away), that is, not compiled by the tex
compiler.
add a comment |
up vote
5
down vote
You can do it quite smoothly using ConTeXt, another TeX engine. It has a mode option that you can pass as an option. When compiling with mode=thismode
, everything enclosed in the proper startmode[thismode] stopmode
pair will be interpreted.
Here is a MWE
startmode[english]
language[en]
stopmode
startmode[espanol]
language[es]
stopmode
starttext
startmode[english]
I love you
stopmode
startmode[espanol]
Te quiero.
stopmode
stoptext
Paste this MWE in mwe.tex and compare the output of context --mode=english mwe.tex
and context --mode=espanol mwe.tex
. If you want to have the two texts next to another, context --mode=english,espanol mwe.tex
will do it.
Works smoothly too. Thank you :)
– i2_
Nov 27 at 11:44
If you think my post was useful, please upvote it, this is the usual way to thank here. You can upvote as many answers as you want (including the one you accepted).
– sztruks
Nov 27 at 12:02
add a comment |
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
13
down vote
accepted
You could use an approach like the following, I use it to create various versions of a CV document.
documentclass{minimal}
usepackage{ifthen}
newboolean{somevariable}
setboolean{somevariable}{false}
begin{document}
ifthenelse{boolean{somevariable}}{Text if somevariable is true.}{Text if somevariable is false.}
end{document}
Works smoothly. This is what i need it. Thank you!!!
– i2_
Nov 27 at 11:43
1
Then please tag my answer as the solution. It helps other to find it more easily.
– Uwe Ziegenhagen
Nov 27 at 15:41
add a comment |
up vote
13
down vote
accepted
You could use an approach like the following, I use it to create various versions of a CV document.
documentclass{minimal}
usepackage{ifthen}
newboolean{somevariable}
setboolean{somevariable}{false}
begin{document}
ifthenelse{boolean{somevariable}}{Text if somevariable is true.}{Text if somevariable is false.}
end{document}
Works smoothly. This is what i need it. Thank you!!!
– i2_
Nov 27 at 11:43
1
Then please tag my answer as the solution. It helps other to find it more easily.
– Uwe Ziegenhagen
Nov 27 at 15:41
add a comment |
up vote
13
down vote
accepted
up vote
13
down vote
accepted
You could use an approach like the following, I use it to create various versions of a CV document.
documentclass{minimal}
usepackage{ifthen}
newboolean{somevariable}
setboolean{somevariable}{false}
begin{document}
ifthenelse{boolean{somevariable}}{Text if somevariable is true.}{Text if somevariable is false.}
end{document}
You could use an approach like the following, I use it to create various versions of a CV document.
documentclass{minimal}
usepackage{ifthen}
newboolean{somevariable}
setboolean{somevariable}{false}
begin{document}
ifthenelse{boolean{somevariable}}{Text if somevariable is true.}{Text if somevariable is false.}
end{document}
answered Nov 27 at 10:32
Uwe Ziegenhagen
9,20343980
9,20343980
Works smoothly. This is what i need it. Thank you!!!
– i2_
Nov 27 at 11:43
1
Then please tag my answer as the solution. It helps other to find it more easily.
– Uwe Ziegenhagen
Nov 27 at 15:41
add a comment |
Works smoothly. This is what i need it. Thank you!!!
– i2_
Nov 27 at 11:43
1
Then please tag my answer as the solution. It helps other to find it more easily.
– Uwe Ziegenhagen
Nov 27 at 15:41
Works smoothly. This is what i need it. Thank you!!!
– i2_
Nov 27 at 11:43
Works smoothly. This is what i need it. Thank you!!!
– i2_
Nov 27 at 11:43
1
1
Then please tag my answer as the solution. It helps other to find it more easily.
– Uwe Ziegenhagen
Nov 27 at 15:41
Then please tag my answer as the solution. It helps other to find it more easily.
– Uwe Ziegenhagen
Nov 27 at 15:41
add a comment |
up vote
15
down vote
There's always docstrip
, which lets you distinguish one code from another using special comments (called guards) and also have code which is common to both.
In my opinion, the advantage of this method over the conditionals is that it's fairly simple to add more languages avoiding the hassle of nesting conditionals.
For instance, you can have a source file (let's call it source.dtx
, but any other name will do):
documentclass{book}
begin{document}
%<english>chapter{LITERATURE}
%<spanish>chapter{LITERATURA}
%<*english>
emph{The Tau Manifesto} is dedicated to one of the most important numbers in
mathematics, perhaps emph{the} most important: the emph{circle constant} relating
the circumference of a circle to its linear dimension. For millennia, the circle has
been considered the most perfect of shapes, and the circle constant captures the
geometry of the circle in a single number. Of course, the traditional choice for
the circle constant is $pi$--but, as mathematician Bob Palais notes in his
delightful article ``$pi$ Is Wrong!'', $pi$ emph{is wrong}. It's time to set
things right.
%</english>
%<*spanish>
emph{El Manifiesto de Tau} está dedicado a uno de los números más importantes en
matemáticas, quizás emph{el} más importante: la emph{constante de círculo} que relaciona
la circunferencia de un círculo con su dimensión lineal. Durante milenios, el círculo ha
sido considerado la forma más perfecta, y la constante del círculo captura la
geometría del círculo en un solo número. Por supuesto, la elección tradicional para
la constante de círculo es $pi$--pero, como señala el matemático Bob Palais en su
artículo encantador ``$pi$ Is Wrong!'', $Pi$ emph{es incorrecto}. Es hora de arreglar las cosas.
%</spanish>
end{document}
(sample text taken from here and Google-Translated to Spanish)
then you only need a so-called “installation file”:
input docstrip % Loads the docstrip program
% Optional switches
askforoverwritefalse % Allows it to overwrite older files without asking
keepsilent % Reduces verbosity
nopreamble % Removes preamble
nopostamble % removes postamble
% Separating sources:
generate{%
%
file{english.tex}{%
from{source.dtx}{english}%
}%
%
file{spanish.tex}{%
from{source.dtx}{spanish}%
}%
%
}
% Exiting
endbatchfile
which will generate an english.tex
file from the parts that are marked as <english>
in the source.dtx
and another one called spanish.tex
from the parts marked with <spanish>
in the source.dtx
. The parts of the source.dtx
which aren't marked go to both output files.
To execute this you only need to run TeX on the installation file:
> pdftex installation.ins
The generated english.tex
will look like this:
documentclass{book}
begin{document}
chapter{LITERATURE}
emph{The Tau Manifesto} is dedicated to one of the most important numbers in
mathematics, perhaps emph{the} most important: the emph{circle constant} relating
the circumference of a circle to its linear dimension. For millennia, the circle has
been considered the most perfect of shapes, and the circle constant captures the
geometry of the circle in a single number. Of course, the traditional choice for
the circle constant is $pi$--but, as mathematician Bob Palais notes in his
delightful article ``$pi$ Is Wrong!'', $pi$ emph{is wrong}. It's time to set
things right.
end{document}
This solution also works and as you said we definitely work on cleaner source tex. But in this case i do not want to create new files. Thank you anyway!
– i2_
Nov 27 at 12:26
2
@i2_ I'm afraid there's no way to usedocstrip
without generating other source files. In fact, this is the purpose ofdocstrip
: to generate usable TeX code from one (or more) source files. But, if you can live with the multiple files (why, not; LaTeX creates a bunch of them anyway :-), since this operates “outside” the TeX run of your document, you don't have to worry about verbatim content being messed up, and you can do some other tricks which aren't possible when you need to keep braces and groups balanced. Pros and cons of each method :)
– Phelype Oleinik
Nov 27 at 12:48
add a comment |
up vote
15
down vote
There's always docstrip
, which lets you distinguish one code from another using special comments (called guards) and also have code which is common to both.
In my opinion, the advantage of this method over the conditionals is that it's fairly simple to add more languages avoiding the hassle of nesting conditionals.
For instance, you can have a source file (let's call it source.dtx
, but any other name will do):
documentclass{book}
begin{document}
%<english>chapter{LITERATURE}
%<spanish>chapter{LITERATURA}
%<*english>
emph{The Tau Manifesto} is dedicated to one of the most important numbers in
mathematics, perhaps emph{the} most important: the emph{circle constant} relating
the circumference of a circle to its linear dimension. For millennia, the circle has
been considered the most perfect of shapes, and the circle constant captures the
geometry of the circle in a single number. Of course, the traditional choice for
the circle constant is $pi$--but, as mathematician Bob Palais notes in his
delightful article ``$pi$ Is Wrong!'', $pi$ emph{is wrong}. It's time to set
things right.
%</english>
%<*spanish>
emph{El Manifiesto de Tau} está dedicado a uno de los números más importantes en
matemáticas, quizás emph{el} más importante: la emph{constante de círculo} que relaciona
la circunferencia de un círculo con su dimensión lineal. Durante milenios, el círculo ha
sido considerado la forma más perfecta, y la constante del círculo captura la
geometría del círculo en un solo número. Por supuesto, la elección tradicional para
la constante de círculo es $pi$--pero, como señala el matemático Bob Palais en su
artículo encantador ``$pi$ Is Wrong!'', $Pi$ emph{es incorrecto}. Es hora de arreglar las cosas.
%</spanish>
end{document}
(sample text taken from here and Google-Translated to Spanish)
then you only need a so-called “installation file”:
input docstrip % Loads the docstrip program
% Optional switches
askforoverwritefalse % Allows it to overwrite older files without asking
keepsilent % Reduces verbosity
nopreamble % Removes preamble
nopostamble % removes postamble
% Separating sources:
generate{%
%
file{english.tex}{%
from{source.dtx}{english}%
}%
%
file{spanish.tex}{%
from{source.dtx}{spanish}%
}%
%
}
% Exiting
endbatchfile
which will generate an english.tex
file from the parts that are marked as <english>
in the source.dtx
and another one called spanish.tex
from the parts marked with <spanish>
in the source.dtx
. The parts of the source.dtx
which aren't marked go to both output files.
To execute this you only need to run TeX on the installation file:
> pdftex installation.ins
The generated english.tex
will look like this:
documentclass{book}
begin{document}
chapter{LITERATURE}
emph{The Tau Manifesto} is dedicated to one of the most important numbers in
mathematics, perhaps emph{the} most important: the emph{circle constant} relating
the circumference of a circle to its linear dimension. For millennia, the circle has
been considered the most perfect of shapes, and the circle constant captures the
geometry of the circle in a single number. Of course, the traditional choice for
the circle constant is $pi$--but, as mathematician Bob Palais notes in his
delightful article ``$pi$ Is Wrong!'', $pi$ emph{is wrong}. It's time to set
things right.
end{document}
This solution also works and as you said we definitely work on cleaner source tex. But in this case i do not want to create new files. Thank you anyway!
– i2_
Nov 27 at 12:26
2
@i2_ I'm afraid there's no way to usedocstrip
without generating other source files. In fact, this is the purpose ofdocstrip
: to generate usable TeX code from one (or more) source files. But, if you can live with the multiple files (why, not; LaTeX creates a bunch of them anyway :-), since this operates “outside” the TeX run of your document, you don't have to worry about verbatim content being messed up, and you can do some other tricks which aren't possible when you need to keep braces and groups balanced. Pros and cons of each method :)
– Phelype Oleinik
Nov 27 at 12:48
add a comment |
up vote
15
down vote
up vote
15
down vote
There's always docstrip
, which lets you distinguish one code from another using special comments (called guards) and also have code which is common to both.
In my opinion, the advantage of this method over the conditionals is that it's fairly simple to add more languages avoiding the hassle of nesting conditionals.
For instance, you can have a source file (let's call it source.dtx
, but any other name will do):
documentclass{book}
begin{document}
%<english>chapter{LITERATURE}
%<spanish>chapter{LITERATURA}
%<*english>
emph{The Tau Manifesto} is dedicated to one of the most important numbers in
mathematics, perhaps emph{the} most important: the emph{circle constant} relating
the circumference of a circle to its linear dimension. For millennia, the circle has
been considered the most perfect of shapes, and the circle constant captures the
geometry of the circle in a single number. Of course, the traditional choice for
the circle constant is $pi$--but, as mathematician Bob Palais notes in his
delightful article ``$pi$ Is Wrong!'', $pi$ emph{is wrong}. It's time to set
things right.
%</english>
%<*spanish>
emph{El Manifiesto de Tau} está dedicado a uno de los números más importantes en
matemáticas, quizás emph{el} más importante: la emph{constante de círculo} que relaciona
la circunferencia de un círculo con su dimensión lineal. Durante milenios, el círculo ha
sido considerado la forma más perfecta, y la constante del círculo captura la
geometría del círculo en un solo número. Por supuesto, la elección tradicional para
la constante de círculo es $pi$--pero, como señala el matemático Bob Palais en su
artículo encantador ``$pi$ Is Wrong!'', $Pi$ emph{es incorrecto}. Es hora de arreglar las cosas.
%</spanish>
end{document}
(sample text taken from here and Google-Translated to Spanish)
then you only need a so-called “installation file”:
input docstrip % Loads the docstrip program
% Optional switches
askforoverwritefalse % Allows it to overwrite older files without asking
keepsilent % Reduces verbosity
nopreamble % Removes preamble
nopostamble % removes postamble
% Separating sources:
generate{%
%
file{english.tex}{%
from{source.dtx}{english}%
}%
%
file{spanish.tex}{%
from{source.dtx}{spanish}%
}%
%
}
% Exiting
endbatchfile
which will generate an english.tex
file from the parts that are marked as <english>
in the source.dtx
and another one called spanish.tex
from the parts marked with <spanish>
in the source.dtx
. The parts of the source.dtx
which aren't marked go to both output files.
To execute this you only need to run TeX on the installation file:
> pdftex installation.ins
The generated english.tex
will look like this:
documentclass{book}
begin{document}
chapter{LITERATURE}
emph{The Tau Manifesto} is dedicated to one of the most important numbers in
mathematics, perhaps emph{the} most important: the emph{circle constant} relating
the circumference of a circle to its linear dimension. For millennia, the circle has
been considered the most perfect of shapes, and the circle constant captures the
geometry of the circle in a single number. Of course, the traditional choice for
the circle constant is $pi$--but, as mathematician Bob Palais notes in his
delightful article ``$pi$ Is Wrong!'', $pi$ emph{is wrong}. It's time to set
things right.
end{document}
There's always docstrip
, which lets you distinguish one code from another using special comments (called guards) and also have code which is common to both.
In my opinion, the advantage of this method over the conditionals is that it's fairly simple to add more languages avoiding the hassle of nesting conditionals.
For instance, you can have a source file (let's call it source.dtx
, but any other name will do):
documentclass{book}
begin{document}
%<english>chapter{LITERATURE}
%<spanish>chapter{LITERATURA}
%<*english>
emph{The Tau Manifesto} is dedicated to one of the most important numbers in
mathematics, perhaps emph{the} most important: the emph{circle constant} relating
the circumference of a circle to its linear dimension. For millennia, the circle has
been considered the most perfect of shapes, and the circle constant captures the
geometry of the circle in a single number. Of course, the traditional choice for
the circle constant is $pi$--but, as mathematician Bob Palais notes in his
delightful article ``$pi$ Is Wrong!'', $pi$ emph{is wrong}. It's time to set
things right.
%</english>
%<*spanish>
emph{El Manifiesto de Tau} está dedicado a uno de los números más importantes en
matemáticas, quizás emph{el} más importante: la emph{constante de círculo} que relaciona
la circunferencia de un círculo con su dimensión lineal. Durante milenios, el círculo ha
sido considerado la forma más perfecta, y la constante del círculo captura la
geometría del círculo en un solo número. Por supuesto, la elección tradicional para
la constante de círculo es $pi$--pero, como señala el matemático Bob Palais en su
artículo encantador ``$pi$ Is Wrong!'', $Pi$ emph{es incorrecto}. Es hora de arreglar las cosas.
%</spanish>
end{document}
(sample text taken from here and Google-Translated to Spanish)
then you only need a so-called “installation file”:
input docstrip % Loads the docstrip program
% Optional switches
askforoverwritefalse % Allows it to overwrite older files without asking
keepsilent % Reduces verbosity
nopreamble % Removes preamble
nopostamble % removes postamble
% Separating sources:
generate{%
%
file{english.tex}{%
from{source.dtx}{english}%
}%
%
file{spanish.tex}{%
from{source.dtx}{spanish}%
}%
%
}
% Exiting
endbatchfile
which will generate an english.tex
file from the parts that are marked as <english>
in the source.dtx
and another one called spanish.tex
from the parts marked with <spanish>
in the source.dtx
. The parts of the source.dtx
which aren't marked go to both output files.
To execute this you only need to run TeX on the installation file:
> pdftex installation.ins
The generated english.tex
will look like this:
documentclass{book}
begin{document}
chapter{LITERATURE}
emph{The Tau Manifesto} is dedicated to one of the most important numbers in
mathematics, perhaps emph{the} most important: the emph{circle constant} relating
the circumference of a circle to its linear dimension. For millennia, the circle has
been considered the most perfect of shapes, and the circle constant captures the
geometry of the circle in a single number. Of course, the traditional choice for
the circle constant is $pi$--but, as mathematician Bob Palais notes in his
delightful article ``$pi$ Is Wrong!'', $pi$ emph{is wrong}. It's time to set
things right.
end{document}
answered Nov 27 at 11:51
Phelype Oleinik
21.2k54380
21.2k54380
This solution also works and as you said we definitely work on cleaner source tex. But in this case i do not want to create new files. Thank you anyway!
– i2_
Nov 27 at 12:26
2
@i2_ I'm afraid there's no way to usedocstrip
without generating other source files. In fact, this is the purpose ofdocstrip
: to generate usable TeX code from one (or more) source files. But, if you can live with the multiple files (why, not; LaTeX creates a bunch of them anyway :-), since this operates “outside” the TeX run of your document, you don't have to worry about verbatim content being messed up, and you can do some other tricks which aren't possible when you need to keep braces and groups balanced. Pros and cons of each method :)
– Phelype Oleinik
Nov 27 at 12:48
add a comment |
This solution also works and as you said we definitely work on cleaner source tex. But in this case i do not want to create new files. Thank you anyway!
– i2_
Nov 27 at 12:26
2
@i2_ I'm afraid there's no way to usedocstrip
without generating other source files. In fact, this is the purpose ofdocstrip
: to generate usable TeX code from one (or more) source files. But, if you can live with the multiple files (why, not; LaTeX creates a bunch of them anyway :-), since this operates “outside” the TeX run of your document, you don't have to worry about verbatim content being messed up, and you can do some other tricks which aren't possible when you need to keep braces and groups balanced. Pros and cons of each method :)
– Phelype Oleinik
Nov 27 at 12:48
This solution also works and as you said we definitely work on cleaner source tex. But in this case i do not want to create new files. Thank you anyway!
– i2_
Nov 27 at 12:26
This solution also works and as you said we definitely work on cleaner source tex. But in this case i do not want to create new files. Thank you anyway!
– i2_
Nov 27 at 12:26
2
2
@i2_ I'm afraid there's no way to use
docstrip
without generating other source files. In fact, this is the purpose of docstrip
: to generate usable TeX code from one (or more) source files. But, if you can live with the multiple files (why, not; LaTeX creates a bunch of them anyway :-), since this operates “outside” the TeX run of your document, you don't have to worry about verbatim content being messed up, and you can do some other tricks which aren't possible when you need to keep braces and groups balanced. Pros and cons of each method :)– Phelype Oleinik
Nov 27 at 12:48
@i2_ I'm afraid there's no way to use
docstrip
without generating other source files. In fact, this is the purpose of docstrip
: to generate usable TeX code from one (or more) source files. But, if you can live with the multiple files (why, not; LaTeX creates a bunch of them anyway :-), since this operates “outside” the TeX run of your document, you don't have to worry about verbatim content being messed up, and you can do some other tricks which aren't possible when you need to keep braces and groups balanced. Pros and cons of each method :)– Phelype Oleinik
Nov 27 at 12:48
add a comment |
up vote
11
down vote
You can use the iflang package:
documentclass{article}
usepackage[english,ngerman]{babel}
usepackage{iflang}
begin{document}
IfLanguageName{english}{This is english}{This is not english}
IfLanguageName{ngerman}{Das ist deutsch}{Das ist nicht deutsch}
selectlanguage{english}
IfLanguageName{english}{This is english}{This not english}
IfLanguageName{ngerman}{Das ist deutsch}{Das ist nicht deutsch}
end{document}
add a comment |
up vote
11
down vote
You can use the iflang package:
documentclass{article}
usepackage[english,ngerman]{babel}
usepackage{iflang}
begin{document}
IfLanguageName{english}{This is english}{This is not english}
IfLanguageName{ngerman}{Das ist deutsch}{Das ist nicht deutsch}
selectlanguage{english}
IfLanguageName{english}{This is english}{This not english}
IfLanguageName{ngerman}{Das ist deutsch}{Das ist nicht deutsch}
end{document}
add a comment |
up vote
11
down vote
up vote
11
down vote
You can use the iflang package:
documentclass{article}
usepackage[english,ngerman]{babel}
usepackage{iflang}
begin{document}
IfLanguageName{english}{This is english}{This is not english}
IfLanguageName{ngerman}{Das ist deutsch}{Das ist nicht deutsch}
selectlanguage{english}
IfLanguageName{english}{This is english}{This not english}
IfLanguageName{ngerman}{Das ist deutsch}{Das ist nicht deutsch}
end{document}
You can use the iflang package:
documentclass{article}
usepackage[english,ngerman]{babel}
usepackage{iflang}
begin{document}
IfLanguageName{english}{This is english}{This is not english}
IfLanguageName{ngerman}{Das ist deutsch}{Das ist nicht deutsch}
selectlanguage{english}
IfLanguageName{english}{This is english}{This not english}
IfLanguageName{ngerman}{Das ist deutsch}{Das ist nicht deutsch}
end{document}
answered Nov 27 at 11:07
Ulrike Fischer
184k7289664
184k7289664
add a comment |
add a comment |
up vote
7
down vote
The comment
package makes it easy to define arbitrary throw-away environments:
documentclass{article}
usepackage{comment}
% define comment sections that are either included or excluded
excludecomment{ENG}
includecomment{GER}
begin{document}
begin{ENG}
In the beginning was the Word, and the Word was with God, and the Word was God.
end{ENG}
begin{GER}
Am Anfang war das Wort und das Wort war bei Gott und Gott war das Wort.
end{GER}
end{document}
If one defines both environments with includecomment
, both will become part of the output.
Technically, this comes close to the docstrip
approach suggested by Phelype Oleinik as the excluded sections are actually gobbled (lexically thrown away), that is, not compiled by the tex
compiler.
add a comment |
up vote
7
down vote
The comment
package makes it easy to define arbitrary throw-away environments:
documentclass{article}
usepackage{comment}
% define comment sections that are either included or excluded
excludecomment{ENG}
includecomment{GER}
begin{document}
begin{ENG}
In the beginning was the Word, and the Word was with God, and the Word was God.
end{ENG}
begin{GER}
Am Anfang war das Wort und das Wort war bei Gott und Gott war das Wort.
end{GER}
end{document}
If one defines both environments with includecomment
, both will become part of the output.
Technically, this comes close to the docstrip
approach suggested by Phelype Oleinik as the excluded sections are actually gobbled (lexically thrown away), that is, not compiled by the tex
compiler.
add a comment |
up vote
7
down vote
up vote
7
down vote
The comment
package makes it easy to define arbitrary throw-away environments:
documentclass{article}
usepackage{comment}
% define comment sections that are either included or excluded
excludecomment{ENG}
includecomment{GER}
begin{document}
begin{ENG}
In the beginning was the Word, and the Word was with God, and the Word was God.
end{ENG}
begin{GER}
Am Anfang war das Wort und das Wort war bei Gott und Gott war das Wort.
end{GER}
end{document}
If one defines both environments with includecomment
, both will become part of the output.
Technically, this comes close to the docstrip
approach suggested by Phelype Oleinik as the excluded sections are actually gobbled (lexically thrown away), that is, not compiled by the tex
compiler.
The comment
package makes it easy to define arbitrary throw-away environments:
documentclass{article}
usepackage{comment}
% define comment sections that are either included or excluded
excludecomment{ENG}
includecomment{GER}
begin{document}
begin{ENG}
In the beginning was the Word, and the Word was with God, and the Word was God.
end{ENG}
begin{GER}
Am Anfang war das Wort und das Wort war bei Gott und Gott war das Wort.
end{GER}
end{document}
If one defines both environments with includecomment
, both will become part of the output.
Technically, this comes close to the docstrip
approach suggested by Phelype Oleinik as the excluded sections are actually gobbled (lexically thrown away), that is, not compiled by the tex
compiler.
answered Nov 27 at 12:56
Daniel
29.1k670150
29.1k670150
add a comment |
add a comment |
up vote
5
down vote
You can do it quite smoothly using ConTeXt, another TeX engine. It has a mode option that you can pass as an option. When compiling with mode=thismode
, everything enclosed in the proper startmode[thismode] stopmode
pair will be interpreted.
Here is a MWE
startmode[english]
language[en]
stopmode
startmode[espanol]
language[es]
stopmode
starttext
startmode[english]
I love you
stopmode
startmode[espanol]
Te quiero.
stopmode
stoptext
Paste this MWE in mwe.tex and compare the output of context --mode=english mwe.tex
and context --mode=espanol mwe.tex
. If you want to have the two texts next to another, context --mode=english,espanol mwe.tex
will do it.
Works smoothly too. Thank you :)
– i2_
Nov 27 at 11:44
If you think my post was useful, please upvote it, this is the usual way to thank here. You can upvote as many answers as you want (including the one you accepted).
– sztruks
Nov 27 at 12:02
add a comment |
up vote
5
down vote
You can do it quite smoothly using ConTeXt, another TeX engine. It has a mode option that you can pass as an option. When compiling with mode=thismode
, everything enclosed in the proper startmode[thismode] stopmode
pair will be interpreted.
Here is a MWE
startmode[english]
language[en]
stopmode
startmode[espanol]
language[es]
stopmode
starttext
startmode[english]
I love you
stopmode
startmode[espanol]
Te quiero.
stopmode
stoptext
Paste this MWE in mwe.tex and compare the output of context --mode=english mwe.tex
and context --mode=espanol mwe.tex
. If you want to have the two texts next to another, context --mode=english,espanol mwe.tex
will do it.
Works smoothly too. Thank you :)
– i2_
Nov 27 at 11:44
If you think my post was useful, please upvote it, this is the usual way to thank here. You can upvote as many answers as you want (including the one you accepted).
– sztruks
Nov 27 at 12:02
add a comment |
up vote
5
down vote
up vote
5
down vote
You can do it quite smoothly using ConTeXt, another TeX engine. It has a mode option that you can pass as an option. When compiling with mode=thismode
, everything enclosed in the proper startmode[thismode] stopmode
pair will be interpreted.
Here is a MWE
startmode[english]
language[en]
stopmode
startmode[espanol]
language[es]
stopmode
starttext
startmode[english]
I love you
stopmode
startmode[espanol]
Te quiero.
stopmode
stoptext
Paste this MWE in mwe.tex and compare the output of context --mode=english mwe.tex
and context --mode=espanol mwe.tex
. If you want to have the two texts next to another, context --mode=english,espanol mwe.tex
will do it.
You can do it quite smoothly using ConTeXt, another TeX engine. It has a mode option that you can pass as an option. When compiling with mode=thismode
, everything enclosed in the proper startmode[thismode] stopmode
pair will be interpreted.
Here is a MWE
startmode[english]
language[en]
stopmode
startmode[espanol]
language[es]
stopmode
starttext
startmode[english]
I love you
stopmode
startmode[espanol]
Te quiero.
stopmode
stoptext
Paste this MWE in mwe.tex and compare the output of context --mode=english mwe.tex
and context --mode=espanol mwe.tex
. If you want to have the two texts next to another, context --mode=english,espanol mwe.tex
will do it.
edited Nov 27 at 11:28
answered Nov 27 at 11:18
sztruks
1,447717
1,447717
Works smoothly too. Thank you :)
– i2_
Nov 27 at 11:44
If you think my post was useful, please upvote it, this is the usual way to thank here. You can upvote as many answers as you want (including the one you accepted).
– sztruks
Nov 27 at 12:02
add a comment |
Works smoothly too. Thank you :)
– i2_
Nov 27 at 11:44
If you think my post was useful, please upvote it, this is the usual way to thank here. You can upvote as many answers as you want (including the one you accepted).
– sztruks
Nov 27 at 12:02
Works smoothly too. Thank you :)
– i2_
Nov 27 at 11:44
Works smoothly too. Thank you :)
– i2_
Nov 27 at 11:44
If you think my post was useful, please upvote it, this is the usual way to thank here. You can upvote as many answers as you want (including the one you accepted).
– sztruks
Nov 27 at 12:02
If you think my post was useful, please upvote it, this is the usual way to thank here. You can upvote as many answers as you want (including the one you accepted).
– sztruks
Nov 27 at 12:02
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461973%2fgenerating-multiple-versions-of-a-document-using-options%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown