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.
Related
The text is too long and will random break my first word over the entire first line...I don't know how to make it look like the other with short text. This is my code:
\documentclass[letterpaper,11pt]{article}
\usepackage{simplecv}
\begin{document}
\vspace{1em}
\entrybig
{\textbf{LexBox}}{Nov 2020 - Present}
LexBox represents the fastest and the most efficient way to make a contravention complaint without to get in touch with a lawyer.
\\\textbf{Technologies:} C\#, ASP.NET, jQuery AJAX, CSS \& HTML
\entrybig
{\textbf{GAM - Group Activity Manager}}{Oct 2020 - Present}
{This application is designed to remote control multiple desktops at the same time. \\
\textbf{Technologies:} C\#, .NET Framework}
\end{document}
and the .sty file is this
and the result is
this
Three major problems:
you must not use \entrybig on its own, it need to be inside a list, e.g. \outerlist{}
The syntax you use for \entrybig is wrong. This macro takes 4 mandatory arguments, not 2, not 3, exactly 4
as this macro gets inserted into table cells, you must not abuse \\ for line breaks
\documentclass[letterpaper,11pt]{article}
% Choose bibliography style for formatting list of publications
\usepackage[style=ieee,url=false,doi=false,maxbibnames=99,sorting=ydnt,dashed=false]{biblatex}
\bibliography{papers}
% Choose theme, e.g. black, RedViolet, ForestGreen, MidnightBlue
\def\theme{MidnightBlue}
\usepackage{simplecv}
\begin{document}
See more of my projects on \website{https://github.com/Mihutzen}
\vspace{1em}
\outerlist{
\entrybig
{\textbf{ETH Zurich}}
{Zurich, CH}
{M.S. in Computer Science, GPA: 5.63/6.00}
{2018\textendash 2020}
}
\end{document}
For some days I am trying to solve the following problem for which I wasn't able to find a solution. Help is very much appreciated.
I am writing a long document and for some sections I would like to print a subset of items from the total bibliography that will be included at the very end before the appendix.
Is there a way do this? I was playing with refsection and imagining something like:
\documentclass[ twoside,openright,titlepage,numbers=noenddot,
headinclude,footinclude,
cleardoublepage=empty,abstract=on,
BCOR=5mm,paper=a4,fontsize=11pt
]{scrreprt}
\usepackage{biblatex}
\addbibresource[label=ownpubs]{ownpubs.bib}
\addbibresource[label=refs]{references.bib}
\begin{document}
%here I want to print a selection of the complete bibliography
%References are required to be consistent throughout the whole document
\chapter*{Related Publications}
\begin{refsection}[references.bib]
\nocite{*}
\printbibliography[heading=none]
\end{refsection}
%here goes all the other stuff: chapters, sections, whatever
%print complete bibliography
\nocite{*}
\printbibliography
\end{document}
ownpubs.bib:
#article{einstein1935can,
title={Can quantum-mechanical description of physical reality be considered complete?},
author={Einstein, Albert and Podolsky, Boris and Rosen, Nathan},
journal={Physical review},
volume={47},
number={10},
pages={777},
year={1935},
publisher={APS}
}
#article{einstein1905movement,
title={On the movement of small particles suspended in stationary liquids required by the molecularkinetic theory of heat},
author={Einstein, A},
journal={Ann. d. Phys},
volume={17},
number={549-560},
pages={1},
year={1905}
}
references.bib:
#article{schrodinger1935gegenwartige,
title={Die gegenw{\"a}rtige Situation in der Quantenmechanik},
author={Schr{\"o}dinger, Erwin},
journal={Naturwissenschaften},
volume={23},
number={50},
pages={844--849},
year={1935},
publisher={Springer-Verlag}
}
With the above code I got the bibliographies printed, but the references (numbers) are not consistent.
Does anyone know a way to approach this problem? I am in no means restricted to splitting the files up. That was just the only solution I was able to come up with.
Thanks for your help and warm Greetings!
You could use a similar approach as in https://tex.stackexchange.com/a/166018 and automatically add some keyword to all entries in references.bib. This will allow you to filter for those when using \printbibliography:
\documentclass[ twoside,openright,titlepage,numbers=noenddot,
headinclude,footinclude,
cleardoublepage=empty,abstract=on,
BCOR=5mm,paper=a4,fontsize=11pt
]{scrreprt}
\usepackage{biblatex}
\addbibresource[label=ownpubs]{ownpubs.bib}
\addbibresource[label=refs]{references.bib}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite]{
\perdatasource{references.bib}
\step[fieldset=keywords, fieldvalue={,Perhalo}, append]
}
}
}
\begin{document}
%here I want to print a selection of the complete bibliography
%References are required to be consistent throughout the whole document
\chapter*{Related Publications}
\printbibliography[heading=none,keyword={Perhalo}]
%here goes all the other stuff: chapters, sections, whatever
%print complete bibliography
\nocite{*}
\printbibliography
\end{document}
I need to write two different abstracts in my thesis in german and in english. The German one works fine and by using the \begin{otherlanguage} command, the abstract name itself changes to english. But furthermore I need to use an english tilte, university name, faculty name and company name for the second abstract. I tried using \renewcommand but it does not change the title in the output file, which is still german.
I found packages for multiple titles (\titling), but that is not working for the university name and so on.
Thank you in advance
\documentclass[11pt, english, ngerman,]{MastersDoctoralThesis}
\thesistitle{Title in German}
\university{University Title in German}
\begin{document}
\begin{abstract}
\addchaptertocentry{\abstractname}
German German German
\end{abstract}
\begin{otherlanguage}{english}
\renewcommand{\thesistitle}{Title in English}
\renewcommand{\university}{University Title in English}
\begin{abstract}
English English English
\end{abstract}
\end{otherlanguage}
% This template was downloaded from:
% http://www.LaTeXTemplates.com
% Template license:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
\documentclass[11pt, english, ngerman,openany]{MastersDoctoralThesis}
\usepackage{blindtext}
\thesistitle{Wombat} % Your thesis title, this is used in the title and abstract, print it elsewhere with \ttitle
\supervisor{Gerald Giraffe} % Your supervisor's name, this is used in the title page, print it elsewhere with \supname
\examiner{} % Your examiner's name, this is not currently used anywhere in the template, print it elsewhere with \examname
\degree{Doctor of Philosophy} % Your degree name, this is used in the title page and abstract, print it elsewhere with \degreename
\author{John \textsc{Smith}} % Your name, this is used in the title page and abstract, print it elsewhere with \authorname
\addresses{} % Your address, this is not currently used anywhere in the template, print it elsewhere with \addressname
\subject{Biological Sciences} % Your subject area, this is not currently used anywhere in the template, print it elsewhere with \subjectname
\keywords{} % Keywords for your thesis, this is not currently used anywhere in the template, print it elsewhere with \keywordnames
\university{Uni der Zootiere} % Your university's name and URL, this is used in the title page and abstract, print it elsewhere with \univname
\department{Institut der Angewandten Tierpflegeranalyse} % Your department's name and URL, this is used in the title page and abstract, print it elsewhere with \deptname
\group{\href{http://researchgroup.university.com}{Research Group Name}} % Your research group's name and URL, this is used in the title page, print it elsewhere with \groupname
\faculty{\href{http://faculty.university.com}{Faculty Name}} % Your faculty's name and URL, this is used in the title page and abstract, print it elsewhere with \facname
\begin{document}
\begin{abstract}
\addchaptertocentry{\abstractname}
\blindtext
\end{abstract}
\begin{otherlanguage}{english}
\makeatletter
\renewcommand{\#title}{Capybara}
\makeatother
\renewcommand{\univname}{Univerity of Zoo Animals}
\renewcommand{\deptname}{Institute for applied Something}
\begin{abstract}
\blindtext
\end{abstract}
\end{otherlanguage}
\end{document}
I do not have, neither know the package MastersDoctoralThesis.
If it includes the babel package, you can use iflang to test the active language.
\documentclass[11pt]{article}
\usepackage{iflang}
\usepackage[german]{babel}
%\usepackage[english]{babel}
\begin{document}
\IfLanguageName{german}{
German German German
}{
English English English
}
\end{document}
If your document class does not include the babel language, you can do something similar by defining a macro and testing its value with the ifthen package.
\documentclass[11pt]{article}
\usepackage{ifthen}
\def\mylanguage{german}
\begin{document}
\ifthenelse{\equal{\mylanguage}{german}}{
German German German
}{
English English English
}
\end{document}
It seems the format in the Reference section is a little off! Can you please show me how to format the citation to list authors' last name first?
Thanks all.
Here is the current form in the Reference section:
C. B. Grimmond, A. Isard, and J. Belding. Development and evaluation of
continuously weighing mini-lysimeters. Agricultural and Forest Meteorology,
62(3-4):205{218, 1992.
I use BibDesk to organize the citation database. Here is what I am using in the TeXstudio:
\documentclass[]{article}
\usepackage[pdftex]{graphicx}
\usepackage[round]{natbib}
\begin{document}
\bibliographystyle{plainnat}
\bibliography{/Users/me/Citation/citation}
\end{document}
You can try to change the Bibtex Bibliography style to 'acm' or 'apalike'
\bibliographystyle{stylename}
\bibliography{bibfile}
Read more about other styles: https://www.sharelatex.com/learn/Bibtex_bibliography_styles
I’m a big fan of ampersands – so much that I heed SimpleBits’ advice to “use the best available ampersand” quite religiously.
For that purpose, I’ve defined the following shortcut in LaTeX:
\let\amp\&
\renewcommand\&{{\scalebox{1.2}{\textnormal{\fontspec{Baskerville}\itshape\amp}}}}
In brief, this changes all uses of the “normal” ampersand to a stylish variant, e.g.:
This is a text \& it contains an ampersand.
(Using \& instead of just & since that’s how LaTeX works – the latter is already reserved to separate columns in table environments.)
However, this always uses the same font – here, Baskerville – no matter whether it fits or not. I’d like to use a different font depending on the font family used. That is, I want to use another ampersand in combination with sans serif text, and in particular I want to prevent rewriting of the ampersand in a monospace context. So in the following two contexts, I don’t want to trigger the above definition:
{\sffamily a \& b}
{\ttfamily a \& b}
How do I do that?
I imagine something like the following:
\renewcommand\&{
\ifsans
{\fontspec{Trebuchet MS}{\textnormal{\itshape\amp}}}
\else
\ifmono
\amp
\else
{\fontspec{Baskerville}\scalebox{1.2}{\textnormal{\itshape\amp}}}
\fi
\fi}
It works the following way:
\documentclass[letterpaper,10pt]{article}
\usepackage[latin1]{inputenc}
\usepackage{german}
\usepackage{geometry}
\geometry{margin=2cm}
\newcommand*\origsffamily{}
\let\origsffamily\sffamily
\renewcommand*\sffamily{\origsffamily\small {\renewcommand\&{{\scalebox{1.2}{\textnormal{\fontspec{Baskerville}\itshape\amp}}}}}}
\begin{document}
hello, this is \& a \sffamily test \&
\end{document}
That means, you include the change of the ampersand sign into the definition of (in my example) \sffamily.
The drawback is - of course - that you have to do this for all desired font families.
You can test for the standard LaTeX token list \f#family, however, this might not be as reliable as you want. The following code simply checks whether the current family equals the default families set by \setmainfont and \setsansfont, but not whether the fonts are really sans-serif:
\documentclass{article}
\usepackage{fontspec}
\usepackage{expl3}
\usepackage{xparse}
\setmainfont{DejaVu Serif}
\setsansfont{DejaVu Sans}
\makeatletter
\ExplSyntaxOn
\NewDocumentCommand \amp { } {
\tl_if_eq:NNTF \f#family \rmdefault {
% this is a roman font
A
} {
\tl_if_eq:NNTF \f#family \sfdefault {
% this is a sans font
B
} {
% something else
C
}
}
}
\ExplSyntaxOff
\makeatother
\begin{document}
test \amp\ test
\sffamily
test \amp\ test
\ttfamily
test \amp\ test
\end{document}