Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
An interlinear gloss can be used to layout a translation of a document.
http://en.wikipedia.org/wiki/Interlinear_gloss
Usually this is done word-by-word or morpheme-by-morpheme. However, I would like to do this in a different way, translating entire paragraphs at a time. The following link and image is an example of what I want done, though I want to do it for a different text which is larger.
http://www.optimnem.co.uk/learning/spanish/three-little-pigs.php
For now I am not interested in taking into account the order of words or phrases that change order between languages. That is, I don't mind if the words in the paragraph are not aligned or if the length of one paragraph is much longer than the other, causing an overhanging line.
As far as I can tell, the following packages do not meet my needs:
covingtn.sty
cgloss4e.sty
gb4e.sty
lingmacros.sty - shortex
Here is the english version:
In the heart of the forest lived three little pigs who were brothers. The wolf always was chasing them in order to eat them. In order to escape the wolf, the pigs decided to make a house each. The smallest made his from straw, to finish first and go out to play. The middle one constructed a cottage from wood. Seeing that his little brother had finished already, he hurried to go and play with him. The oldest worked on his house of brick. 'You'll soon see what the wolf does with your houses,' he scolded his brothers but they were having a great time.
Here is the spanish version:
En el corazón del bosque vivían tres cerditos que eran hermanos. El lobo siempre andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron hacerse una casa. El pequeño la hizo de paja, para acabar antes y poder irse a jugar. El mediano construyó una casita de madera. Al ver que su hermano perqueño había terminado ya, se dio prisa para irse a jugar con él. El mayor trabajaba en su casa de ladrillo. - Ya veréis lo que hace el lobo con vuestras casas - riñó a sus hermanos mientras éstos se lo pasaban en grande.
I don't want to do it manually like this:
\documentclass{article}
\usepackage[margin=1in, paperwidth=8.5in, paperheight=11in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{url}
\begin{document}
\noindent
\url{http://www.optimnem.co.uk/learning/spanish/three-little-pigs.php}\\
\\
\indent
En el corazón del bosque vivían tres cerditos que eran hermanos. El lobo siempre\\
\indent
In the heart of the forest lived three little pigs who were brothers. The wolf always\\
\\
%
andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron\\
was chasing them in order to eat them. In order to escape the wolf, the pigs decided to\\
\\
%
hacerse una casa. El pequeño la hizo de paja, para acabar antes y poder irse a jugar.\\
make a house each. The smallest made his from straw, to finish first and go out to play.\\
\\
%
El mediano construyó una casita de madera. Al ver que su hermano perqueño había\\
The middle one constructed a cottage from wood. Seeing that his little brother had\\
\\
%
terminado ya, se dio prisa para irse a jugar con él. El mayor trabajaba en su casa de\\
finished already, he hurried to go and play with him. The oldest worked on his house of\\
\\
%
ladrillo. - Ya veréis lo que hace el lobo con vuestras casas - riñó a sus hermanos\\
brick. 'You'll soon see what the wolf does with your houses,' he scolded his brothers\\
\\
%
mientras éstos se lo pasaban en grande.\\
but they were having a great time.\\
\\
\end{document}\\
I would like to use a package or a macro to automatically have the english and spanish texts interspersed with line breaks when the end of the line has been reached for each. How can I layout this simple dual-line biligual paragraph in Latex in a more automated way (without manually adding line breaks)?
The following hack may help you achieve your goal. It's based on the idea of a zero-height minipage to overlap two triple-spaced minipages.
I'll use placeholders for the English and Spanish text (\english and \spanish respectively). Also, be sure to include the setspace package:
\usepackage{setspace}
\def\english{In the heart of the forest lived three little pigs who were brothers. The wolf always was chasing them in order to eat them. In order to escape the wolf, the pigs decided to make a house each. The smallest made his from straw, to finish first and go out to play. The middle one constructed a cottage from wood. Seeing that his little brother had finished already, he hurried to go and play with him. The oldest worked on his house of brick. 'You'll soon see what the wolf does with your houses,' he scolded his brothers but they were having a great time.}
\def\spanish{En el corazón del bosque vivían tres cerditos que eran hermanos. El lobo siempre andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron hacerse una casa. El pequeño la hizo de paja, para acabar antes y poder irse a jugar. El mediano construyó una casita de madera. Al ver que su hermano perqueño había terminado ya, se dio prisa para irse a jugar con él. El mayor trabajaba en su casa de ladrillo. - Ya veréis lo que hace el lobo con vuestras casas - riñó a sus hermanos mientras éstos se lo pasaban en grande.}
By giving the top block a height of 0pt we allow for the next minipage to overlap it.
\begin{minipage}[t][0pt]{\linewidth}
\setstretch{3}
\english
\end{minipage}
\begin{minipage}[t]{\linewidth}
\setstretch{3}
\spanish
\end{minipage}
The primary One of the problems with this idea is that if the zero-height section is longer than the regular section, then you'll have some lingering overlapping text to deal with. (Edit: This problem is addressed in the comment below, note that line-breaks will also be a serious drawback to this idea.)
The result (in part):
I don't think there is a package to do what you want, but it is possible to implement this yourself using \vsplit, which is well documented in Tex by Topic (availble for free download, or in the dead-tree edition via Lulu). The basic idea is
You define two vboxes, one for the English, one for the Spanish, and you want to take out the contents one line at a time. Call these vboxes \ENbox and \ESbox;
You need to determine the correct vertical dimension to use: this might be \lineheight, or you might need a different value, you will have to experiment. Assuming \lineheight is right ...
... then you can get the next line of English using \setbox\nextline=\vsplit\ENbox to \lineheight, which you can output using \unvbox\ENbox, then likewise the next line from \ESbox, then some vertical space for the intergloss gap;
Then you need to test the loop, which you can do by querying the vertical heights, using \ht, of \ENbox and \ESbox. This bit will be fiddly.
All-in-all, this will be somewhat tricky coding: good luck, and don't hesitate to ask questions here if you run into difficulties.
Postscript This is obviously much more work than Geoff's much simpler solution, which for some reason I hadn't seen when I wrote this, but it should be more flexible if you want to fiddle with it.
If you want to interlace Spanish and English paragraphs, and have them line up approximately correctly, then what you want is to write your translations word-by-word (or several words by several words), and use a gloss package that can wrap long sentences. I've done this before using gloss.sty. An example of its use(the goal was to gloss each word with its part of speech):
\gloss Both knowledge and wisdom extend man's reach. Knowledge led to
cjc nn0 cjc nn0 vvb {nn0 pos} {nn0 pun} nn0 vvd prp
\gloss computers, wisdom to chopsticks. Unfortunately our association is
{nn2 pun} nn0 prp {nn2 pun} av0 dps nn1 vbz
\gloss overinvolved with the former. The latter will have to wait for a
ad0 prp at0 {nn0 pun} at0 nn0 vm0 vhb to0 vvb avp at0
\gloss more sublime day.
av0 aj0 {nn1 pun}
\unhbox\gline
The package lines things up words from the first language with words from the second "language" using spaces. To line up multiple words in one language with a single word (or multiple words) from the other language, use braces to group the multiple words. Though the lines here are interlaced, this is just for my editing convenence. You could write really long lines if you wanted to, and the gloss algorithm will wrap them properly.
I've also used a two-column paragraph-by-paragraph approach using the parallel package.
put an extra line break in between each set of lines:
%
andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron
was chasing them in order to eat them. In order to escape the wolf, the pigs decided to
%
Related
Can you please help me to find the error? I think it's ok the first part, but i can't find the error with the equation that should be a system.
'''\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\title{Test di \LaTeX del Laboratorio di Comunicazione
mediante Calcolatore}
\author{Sara Pia Ciccotosto \\
\textbf{s.ciccotosto#studenti.unipi.it}}
\begin{document}
\maketitle
\section{Teorema del laboratorio}
\subsection{ L’enunciato classico}
\paragraph{Scopo di queste note `e dimostrare in modo formale un risultato noto in letterature come \textit{Teorema del Laboratorio}. Si tratta di un risultato che ha un ruolo
fondamentale nella trattazione analitica di alcuni problemi di Cauchy, come il
seguente:
\begin{equation}
\begin{cases}
\frac{dy(x)}{dx} = 1+x^2 y(x) \\
y(0)=0
\end{cases}
\end{equation}'''
this is the output:
Runaway argument?
{Scopo di queste note `e dimostrare in modo formale un risultato noto\ETC.
! File ended while scanning use of \#xdblarg.
<inserted text>
\par
<*> "./test lcmc.tex"
?
and in "Error, warnings and badboxes" is written "File ended while scanning use of #xdblarg"
Thank you!
I was wondering if there would be a feature that would allow me to write code
Je [te/vous] présente.
that would allow me to generate two versions:
Je te présente.
Je vous présente.
The idea is to have only one PDFLaTeX document and to generate a version in tutoiement and a version in vouvoiement.
There are many packages which allow to produce multiple versions from the same source, e.g. the beameraudience package. However you could also create a simple switch yourself:
\documentclass{article}
\newif\ifvous
%\voustrue %try with and without this line
\newcommand{\switch}[2]{%
\ifvous%
#1%
\else%
#2%
\fi%
}
\begin{document}
Je \switch{vous}{te} présente.
\end{document}
If you would like to automatically produce two pdfs without commenting/uncommenting anything in the source, you could use the same techniques as shown in https://topanswers.xyz/tex?q=583
the players on my server are joining with Emojis on his names and that is not permitted, I tried to create a if check, but it doesn't work properly
if string.find(playerName, "%^") or string.find(playerName, '%\') then
deferrals.done("Por favor, elimine sus emojis y códigos de color de su nombre.")
end
The syntax highlighting already tells you what's wrong: \ is used in Lua as an escape character, so the ' behind it doesn't close the string which instead goes on until the next ' smoewhere in your code. Use \\ if you want a single \
if playerName:find("%^") or playerName:find("%\\") then
deferrals.done("Por favor, elimine sus emojis y códigos de color de su nombre.")
end
By the way; if you don't need patterns in your search, you can disable them by passing false as the second argument to string.find:
if playerName:find([[^]], 1, false) or playerName:find([[\]], 1, false) then
deferrals.done("Por favor, elimine sus emojis y códigos de color de su nombre.")
end
And just in case, try adding an or true to the condition, so it activates for all player names; that way you can find out if it's the condition itself that fails, or the code inside the if block.
I am writing my thesis with two languages, i.e. English and French. I have written algorithm using algorithm2e in English. However, in one of the sections I also need to write algorithm in French. How can I achieve this? I mean I want to change all keywords in the algorithm into French in just one section and not the whole latex document.
algorithm2e provides package options french and frenchkw. The former changes, amongst other things, the names associated with \captions in algorithm. The latter provides French keywords that you can use.
If you want to use both English and French algorithms, then load the algorithm2e package under one option, and define the additional keywords as provided by the package. Below is a small example (I don't speak French):
\documentclass{article}
\usepackage{algorithm2e}
% French keywords:
\SetKwInput{KwRes}{R\'esultat}%
\SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{fin si}%
\SetKwFor{Tq}{tant que}{faire}{fin tq}%
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms in English}
\end{algorithm}
\begin{algorithm}[H]
\renewcommand{\algorithmcfname}{Algorithme}%
\SetAlgoLined
\KwData{this text}
\KwRes{how to write algorithm with \LaTeX2e }
initialization\;
\Tq{not at end of this document}{
read current\;
\eSi{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms in French}
\end{algorithm}
\end{document}
Here is the complete definition of content for English algorithms (taken from algorithm2e.sty):
\renewcommand{\listalgorithmcfname}{List of Algorithms}%
\renewcommand{\algorithmcfname}{Algorithm}%
\renewcommand{\algorithmautorefname}{algorithm}%
\renewcommand{\algorithmcflinename}{line}%
\renewcommand{\algocf#typo}{}%
\renewcommand{\#algocf#procname}{Procedure}%
\renewcommand{\#algocf#funcname}{Function}%
\renewcommand{\procedureautorefname}{procedure}%
\renewcommand{\functionautorefname}{function}%
\renewcommand{\algocf#languagechoosen}{english}%
\SetKwHangingKw{KwHData}{Data$\rightarrow$}
\SetKwInput{KwIn}{Input}%
\SetKwInput{KwOut}{Output}%
\SetKwInput{KwData}{Data}%
\SetKwInput{KwResult}{Result}%
\SetKw{KwTo}{to}
\SetKw{KwRet}{return}%
\SetKw{Return}{return}%
\SetKwBlock{Begin}{begin}{end}%
\SetKwRepeat{Repeat}{repeat}{until}%
%
\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end if}%
\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{end switch}%
\SetKwFor{For}{for}{do}{end for}%
\SetKwFor{ForPar}{for}{do in parallel}{end forpar}
\SetKwFor{ForEach}{foreach}{do}{end foreach}%
\SetKwFor{ForAll}{forall}{do}{end forall}%
\SetKwFor{While}{while}{do}{end while}%
Here is the complete definition of content for French algorithms (taken from algorithm2e.sty):
\renewcommand{\listalgorithmcfname}{Liste des Algorithmes}%
\renewcommand{\algorithmcfname}{Algorithme}%
\renewcommand{\algorithmautorefname}{algorithme}%
\renewcommand{\algorithmcflinename}{ligne}%
\renewcommand{\algocf#typo}{\ }%
\renewcommand{\#algocf#procname}{Proc\'edure}%
\renewcommand{\#algocf#funcname}{Fonction}%
\renewcommand{\procedureautorefname}{proc\'edure}%
\renewcommand{\functionautorefname}{fonction}%
\renewcommand{\algocf#languagechoosen}{french}%
\SetKwHangingKw{HDonnees}{Donnees$\rightarrow$}
\SetKwInput{Donnees}{Donn\'ees}%
\SetKwInput{Res}{R\'esultat}%
\SetKwInput{Entree}{Entr\'ees}%
\SetKwInput{Sortie}{Sorties}%
\SetKw{KwA}{\`a}%
\SetKw{Retour}{retourner}%
\SetKwBlock{Deb}{d\'ebut}{fin}%
\SetKwRepeat{Repeter}{r\'ep\'eter}{jusqu'\`a}%
%
\SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{fin si}%
\SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin cas}{fin d'alternative}%
\SetKwFor{Pour}{pour}{faire}{fin pour}%
\SetKwFor{PourPar}{pour}{faire en parall\`ele}{fin pour}%
\SetKwFor{PourCh}{pour chaque}{faire}{fin pour chaque}%
\SetKwFor{PourTous}{pour tous les}{faire}{fin pour tous}%
\SetKwFor{Tq}{tant que}{faire}{fin tq}%
If you use any of the definition containing an # (like \renewcommand{\#algocf#procname}{Proc\'edure}, for example), you'll have to surround the redefinition using a \makeatletter...\makeatother pair.
Problem: I have a bunch of txt files written in Portuguese on a Windows machine using NotePad. Some of them seem to have been encoded as ANSI. When I open these files using gedit on Ubuntu, some of them contain boxes containing 008D (see screenshot). This is after converting them to UTF-8.
When I print the file contents to the terminal using cat, head or more, this is the output of the same file. Note that everything from última vez up to and including the strange character isn't printed to the terminal.
Olá madrinha! Eu gostava de ir contigo passar férias na montanha, porque acho que vai ser divertido e há muito tempo que já não vou a tua casa e na últimaar a ter saudades. Madrinha, não sei porque és tão simpática comigo mas para mim, és a melhor madrinha do mundo inteiro. Madrinha, ajudas-me sempre que preciso e estás sempre a apoiar-me por isso, quero ir a tua casa para te apoiar a ti. Obrigada madrinha, por me apoiares. Muito obrigado madrinha
When I open the same file using atom.io, everything looks as it should:
Questions: Most pressingly: How can I get rid of this character without opening all files and manually deleting them? And secondly, what is this, i.e., what should I google to solve similar problems?
Found the magical keywords ('remove unicode string using sed'). This does the trick: https://stackoverflow.com/a/8562661/1331521:
# Define unicode character you want to remove;
# In this case 008D:
CHARS=$(python -c 'print u"\u008D".encode("utf8")')
# Then run sed on all files in directory
sed -i 's/['"$CHARS"']//g' *