1

In the masters-doctoral-thesis template, the language is chosen when the document class is called in the main and is applied to the whole thesis. However, I would like to mention some proverbs in Arabic in one specific page. Is this possible?

Here is my MWE:

\documentclass[
10=2pt, % The default document font size, options: 10pt, 11pt, 12pt
%oneside, % Two side (alternating margins) for binding by default, uncomment to switch to one side
english, % ngerman for German
singlespacing, % Single line spacing, alternatives: onehalfspacing or doublespacing
%draft, % Uncomment to enable draft mode (no pictures, no links, overfull hboxes indicated)
%nolistspacing, % If the document is onehalfspacing or doublespacing, uncomment this to set spacing in lists to single
liststotoc, % Uncomment to add the list of figures/tables/etc to the table of contents
toctotoc, % Uncomment to add the main table of contents to the table of contents
parskip, % Uncomment to add space between paragraphs
nohyperref, % Uncomment to not load the hyperref package
headsepline, % Uncomment to get a line under the header
%chapterinoneline, % Uncomment to place the chapter title next to the number on one line
%consistentlayout, % Uncomment to change the layout of the declaration, abstract and acknowledgements pages to match the default layout
]{MastersDoctoralThesis} % The class file specifying the document structure

\usepackage[utf8]{inputenc} % Required for inputting international characters \usepackage[T1]{fontenc} % Output font encoding for international characters \usepackage{ragged2e} \usepackage{booktabs,multirow} \usepackage{tikz} \usetikzlibrary{arrows,arrows.meta,fit,matrix,shapes,positioning,decorations.pathreplacing,calc,calligraphy,shadows} \usepackage{svg} \usepackage{graphicx} \usepackage{amsmath} \usepackage{setspace} \usepackage{xcolor} \usepackage{csquotes} \usepackage{color} \usepackage{colortbl} \definecolor{darkgreen}{RGB}{0,100,0} \definecolor{khrawi2}{RGB}{220,200,90} \definecolor{khrawi}{RGB}{85,34,0} \definecolor{yellow}{RGB}{255,255,0} \definecolor{noir}{RGB}{0,0,0} \definecolor{gray}{RGB}{200,51,51} \definecolor{mapink}{RGB}{255,169,169} \definecolor{mablue}{RGB}{33,190,208} \definecolor{hotpink}{RGB}{255,105,180} \colorlet{linkequation}{darkgreen} \usepackage{enumitem} \usepackage{nicematrix} \usepackage{subcaption} \captionsetup[subfigure]{labelfont=rm} \usepackage{circuitikz} \usepackage{lettrine} \usepackage{geometry} \usepackage{amssymb} \usepackage{asymptote} \usepackage{mathtools} \usepackage{etoc} \usepackage{xfrac} \usepackage{nicefrac} \usepackage{subcaption} \usepackage{bigdelim} \usepackage{datetime} \usepackage{slashbox} \usepackage{scalefnt} \usepackage{float} \usepackage{tocloft} \usepackage{mathpazo} \usepackage[style=ieee,backend=bibtex]{biblatex} \usepackage[bottom]{footmisc} \usepackage{array}

%------------------------------------------------------------------------------------- % MARGIN SETTINGS %-------------------------------------------------------------------------------------

\geometry{ % papersize={176mm,256mm} paper=b5paper,left=15mm,right=15mm,top=6mm,bottom=6mm,layouthoffset=3mm,layoutvoffset=3mm }

\begin{document}

I need a new page here where I say stuff in arabic and then switch back to english

%example of what I want to say in arabic وَيَجهَدُ الناسُ في الدُنيا مُنافَسَةً % وَلَيسَ لِلناسِ شَيءٌ غَيرَ ما رُزِقوا

\end{document}

Ingmar
  • 6,690
  • 5
  • 26
  • 47

1 Answers1

1

I’m assuming you are using the document class found in this repository: https://github.com/jaredjstewart/Masters-Project , and… it has a lot going on plus all the packages you are using, but there is a quick solution (I think) that may help you.

Quick solution

Use the arabtex package following the instructions found in Overleaf! The only patching necessary in your code is to add said package, call the utf8 package and setup the Unicode inputs. Then you can use Arabic text inside a custom environment called “RLtext”. That part of your code should look like this:

% A lot of packages above
\usepackage{array}
\usepackage{arabtex}
\usepackage{utf8}

%------------------------------------------------------------------------------------- % MARGIN SETTINGS %-------------------------------------------------------------------------------------

\geometry{ % papersize={176mm,256mm} paper=b5paper,left=15mm,right=15mm,top=6mm,bottom=6mm,layouthoffset=3mm,layoutvoffset=3mm } \setcode{utf8}

\begin{document}

I need a new page here where I say stuff in arabic and then switch back to english

Example of what I want to say in arabic: \begin{RLtext}
وَيَجهَدُ الناسُ في الدُنيا مُنافَسَةً

وَلَيسَ لِلناسِ شَيءٌ غَيرَ ما رُزِقوا \end{RLtext}

But I can do english right away now! \end{document}

The RLtext environment should only contain Arabic characters, Latin characters will get discarded if you use them inside that environment. The output should look like this!

Output 1

If you really need to combine English and Arabic in the same line, you can use the \RL command as follows:

This text is in \RL{اَلْعَرَبيَّةُ}!

Which yields:

Output2

A better solution

The previous solution relies on a font style defined in the arabtex package, and I’m not sure how customizable that is or if you’ll be able to work around it with italicization, bold faces, etc. A better way to handle multilingual text is by using another font, which is done mostly in XeTeX or LuaTeX. Most Windows fonts have a full character map for Arabic characters for several fonts, so you can try changing them using fontspec as shown in this example using any font you like and simply pasting your Arabic text as-is without much modification!

Now, for extended features, you may want to patch too the babel package which is called in the MasterDoctoralThesis class, it is found in line 129 and that part should look like this:

% A lot above...
%----------------------------------------------------------------------------------------
%   REQUIRED PACKAGES
%----------------------------------------------------------------------------------------

\usepackage{babel} % Required for automatically changing names of document elements to languages besides english

\RequirePackage{scrbase} % Required for handling language-dependent names of sections/document elements

\RequirePackage{scrhack} % Loads fixes for various packages % A lot below...

The patch you may want to apply if you go this route is the following.

% A lot above...
%----------------------------------------------------------------------------------------
%   REQUIRED PACKAGES
%----------------------------------------------------------------------------------------

\usepackage[utf8]{inputenc} \usepackage[LAE,LFE]{fontenc} \usepackage[english,farsi,arabic]{babel} % Required for automatically changing names of document elements to languages besides english

\RequirePackage{scrbase} % Required for handling language-dependent names of sections/document elements

\RequirePackage{scrhack} % Loads fixes for various packages % A lot below...

This will allow you to use Arabic or any other language however and whenever you want, provided you use \selectlanguage each time you need to swap from English to other. The full extent of this method can be seen in this manual.

Hope that helps!

  • I don't know the difference but to be more specific this the one I use https://www.latextemplates.com/template/masters-doctoral-thesis. Using babel and arabtex generate these errors that make no sense to me at all. Then mention some extra { in a random equation somewhere – Wallflower Jul 08 '23 at 23:19
  • @Wallflower Yep! Seems to be similar, but in the version you have, babel is defined at line 186 and not at line 129 of MastersDoctoralThesis.cls.

    If you are going for the simple solution, you don’t need to change or re-declare babel, as this one only pastes Arabic text as-is without doing anything fancy. If you want to configure babel to use Arabic, you do not need arabtex. The reason why you get errors, is because by defining inputec causes conflicts with the mathpazo package. Having a proper font and not using this package solves the issue.

    –  Jul 08 '23 at 23:47
  • When you say 'not using this package' you mean the "mathpazo" right? Because when I delete it everything goes nuts and the pdf just won't generate anymore x) --It is a PhD manuscript I am writing-- – Wallflower Jul 09 '23 at 09:56
  • @Wallflower Does your institution requires you to use MastersDoctoralThesis.cls? Given that you use way too many packages, maybe you would want to use the default classes and just setup the format yourself.

    The reason why mathpazo crashes with the inputec or utf8 encoding is because it causes conflict with other character maps. If you do need the Palatino font, consider using the actual Palatino font and configure it via fontspec and unicode-math so you can input the glyphs directly without any errors. Although I’m not sure if Palatino has support for Arabic glyphs.

    –  Jul 09 '23 at 17:16
  • It is actually too late to look into that (need to submit the manuscript in few hours) and yes my institution requires this class specifically. I was thinking maybe generate the page I want written in arabic and merge it with my manuscript in case nothing works, what do u think? – Wallflower Jul 09 '23 at 17:18
  • 1
    @Wallflower That’s not the ideal but… if you are in need to do something super quick, that can do the following:

    Use the class you already use to generate a new page with just the basics, erase all the extra dependencies and use the first solution I proposed to generate the single page in Arabic. Then you can edit the pdf manually adding the new page were you need it.

    Again, that’s not the ideal, but since you are in a rush… as long as it works!

    –  Jul 09 '23 at 17:23
  • Understood, thank you so much!! – Wallflower Jul 09 '23 at 17:24