LaTeX forum ⇒ Text FormattingFull justify with greek text

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
bstex
Posts: 27
Joined: Mon Oct 23, 2017 10:22 am

Full justify with greek text

Postby bstex » Wed Oct 25, 2017 10:51 am

Hi.
Does anyone know why this is happening with the justify on my Greek text? Some letters are going OUT of the justify line. It doesn't happen when I type English text.
Maybe hyphenation is a solution, but I would like not to use hyphenation on Greek text.
justify.png
justify.png (57.25 KiB) Viewed 231 times

Thank you in advance.

P.S. The text on the image contains understandable Greek words. Don't try to understand them. :)

User avatar
Stefan Kottwitz
Site Admin
Posts: 8522
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Wed Oct 25, 2017 3:01 pm

Hi,

it looks like hyphenation is disabled. This could be a property of the font. And you may need to load the right font encoding. Loading the microtype package may help too.

Can you post a small compilable code with the document settings in your preamble (same font settings, same page width etc.) with that text as sample, so we can test a fix? If the text contains some information, you don't want to see online, we can remove the text after the problem is solved.

Stefan
Site admin

bstex
Posts: 27
Joined: Mon Oct 23, 2017 10:22 am

Postby bstex » Thu Oct 26, 2017 2:55 pm

Hi,
I changed my main font to "Times New Roman" and I have the same problem, so I don't think that the problem is the "Myriad Pro" font that I use.

My "structure.tex" file contains this code:

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. % The Legrand Orange Book
  3. % Structural Definitions File
  4. % Version 2.0 (9/2/15)
  5. %
  6. % Original author:
  7. % Mathias Legrand (legrand.mathias@gmail.com) with modifications by:
  8. % Vel (vel@latextemplates.com)
  9. %
  10. % This file has been downloaded from:
  11. % <!-- m --><a class="postlink" href="http://www.LaTeXTemplates.com">http://www.LaTeXTemplates.com</a><!-- m -->
  12. %
  13. % License:
  14. % CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
  15. %
  16. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  17.  
  18. %----------------------------------------------------------------------------------------
  19. % VARIOUS REQUIRED PACKAGES AND CONFIGURATIONS
  20. %----------------------------------------------------------------------------------------
  21. \usepackage[table]{xcolor}
  22.  
  23. \usepackage[top=2.5cm,bottom=2.5cm,inner=3cm,outer=2cm,headsep=10pt,a4paper]{geometry} % Page margins
  24.  
  25. \linespread{1.1}
  26.  
  27. \usepackage{graphicx} % Required for including pictures
  28. \graphicspath{{Pictures/}} % Specifies the directory where pictures are stored
  29.  
  30. \usepackage{lipsum} % Inserts dummy text
  31.  
  32. \usepackage{tikz} % Required for drawing custom shapes
  33.  
  34. \usepackage[english]{babel} % English language/hyphenation
  35.  
  36. \usepackage{enumitem} % Customize lists
  37. \setlist{nolistsep} % Reduce spacing between bullet points and numbered lists
  38.  
  39. \usepackage{booktabs} % Required for nicer horizontal rules in tables
  40.  
  41. \usepackage{xcolor} % Required for specifying colors by name
  42. \definecolor{ocre}{RGB}{243,102,25} % Define the orange color used for highlighting throughout the book
  43.  
  44. \usepackage{array}
  45.  
  46. \usepackage[version=4]{mhchem}
  47.  
  48. \usepackage{tcolorbox}
  49.  
  50. \usepackage[version=4]{mhchem}
  51. \mhchemoptions{textfontcommand=\sffamily}
  52. \mhchemoptions{mathfontcommand=\mathsf}
  53.  
  54. \usetikzlibrary{positioning,shapes.callouts}
  55.  
  56. %----------------------------------------------------------------------------------------
  57. % FONTS
  58. %----------------------------------------------------------------------------------------
  59.  
  60. \usepackage{avant} % Use the Avantgarde font for headings
  61. \usepackage{times} % Use the Times font for headings
  62. \usepackage{mathptmx} % Use the Adobe Times Roman as the default text font together with math symbols from the Sym­bol, Chancery and Com­puter Modern fonts
  63.  
  64. \usepackage{microtype} % Slightly tweak font spacing for aesthetics
  65. \usepackage[utf8]{inputenc} % Required for including letters with accents
  66. \usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
  67.  
  68. \usepackage{fontspec}
  69.  
  70. \usepackage{titlesec}
  71. \defaultfontfeatures{Ligatures=TeX}
  72. \setsansfont{Times New Roman}
  73. \setmainfont{Myriad Pro}
  74.  
  75. %----------------------------------------------------------------------------------------
  76. % BIBLIOGRAPHY AND INDEX
  77. %----------------------------------------------------------------------------------------
  78.  
  79. \usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]{biblatex}
  80. \addbibresource{bibliography.bib} % BibTeX bibliography file
  81. \defbibheading{bibempty}{}
  82.  
  83. \usepackage{calc} % For simpler calculation - used for spacing the index letter headings correctly
  84. \usepackage{makeidx} % Required to make an index
  85. \makeindex % Tells LaTeX to create the files required for indexing
  86.  
  87.  
  88. %----------------------------------------------------------------------------------------
  89. % THEOREM STYLES
  90. %----------------------------------------------------------------------------------------
  91.  
  92. \usepackage{amsmath,amsfonts,amssymb,amsthm} % For math equations, theorems, symbols, etc
  93.  
  94. \newcommand{\intoo}[2]{\mathopen{]}#1\,;#2\mathclose{[}}
  95. \newcommand{\ud}{\mathop{\mathrm{{}d}}\mathopen{}}
  96. \newcommand{\intff}[2]{\mathopen{[}#1\,;#2\mathclose{]}}
  97. \newtheorem{notation}{Notation}[chapter]
  98.  
  99. % Boxed/framed environments
  100. \newtheoremstyle{ocrenumbox}% % Theorem style name
  101. {0pt}% Space above
  102. {0pt}% Space below
  103. {\normalfont}% % Body font
  104. {}% Indent amount
  105. {\small\bf\sffamily\color{ocre}}% % Theorem head font
  106. {\;}% Punctuation after theorem head
  107. {0.25em}% Space after theorem head
  108. {\large\sffamily\color{lightblue4}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
  109. \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}} % Optional theorem note
  110. \renewcommand{\qedsymbol}{$\blacksquare$}% Optional qed square
  111.  
  112. \newtheoremstyle{blacknumex}% Theorem style name
  113. {5pt}% Space above
  114. {5pt}% Space below
  115. {\normalfont}% Body font
  116. {} % Indent amount
  117. {\small\bf\sffamily}% Theorem head font
  118. {\;}% Punctuation after theorem head
  119. {0.25em}% Space after theorem head
  120. {\small\sffamily{\tiny\ensuremath{\blacksquare}}\nobreakspace\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
  121. \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}% Optional theorem note
  122.  
  123. \newtheoremstyle{blacknumbox} % Theorem style name
  124. {0pt}% Space above
  125. {0pt}% Space below
  126. {\normalfont}% Body font
  127. {}% Indent amount
  128. {\small\bf\sffamily}% Theorem head font
  129. {\;}% Punctuation after theorem head
  130. {0.25em}% Space after theorem head
  131. {\small\sffamily\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
  132. \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}% Optional theorem note
  133.  
  134. % Non-boxed/non-framed environments
  135. \newtheoremstyle{ocrenum}% % Theorem style name
  136. {5pt}% Space above
  137. {5pt}% Space below
  138. {\normalfont}% % Body font
  139. {}% Indent amount
  140. {\small\bf\sffamily\color{ocre}}% % Theorem head font
  141. {\;}% Punctuation after theorem head
  142. {0.25em}% Space after theorem head
  143. {\small\sffamily\color{ocre}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
  144. \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}} % Optional theorem note
  145. \renewcommand{\qedsymbol}{$\blacksquare$}% Optional qed square
  146. \makeatother
  147.  
  148. % Defines the theorem text style for each type of theorem to one of the three styles above
  149. \newcounter{dummy}
  150. \numberwithin{dummy}{section}
  151. \theoremstyle{ocrenumbox}
  152. \newtheorem{theoremeT}[dummy]{Theorem}
  153. \newtheorem{problem}{Problem}[chapter]
  154. \newtheorem{exerciseT}{}[chapter]
  155. \theoremstyle{blacknumex}
  156. \newtheorem{exampleT}{Example}[chapter]
  157. \theoremstyle{blacknumbox}
  158. \newtheorem{vocabulary}{Vocabulary}[chapter]
  159. \newtheorem{definitionT}{Definition}[section]
  160. \newtheorem{corollaryT}[dummy]{Corollary}
  161. \theoremstyle{ocrenum}
  162. \newtheorem{proposition}[dummy]{Proposition}
  163.  
  164. %----------------------------------------------------------------------------------------
  165. % DEFINITION OF COLORED BOXES
  166. %----------------------------------------------------------------------------------------
  167.  
  168. \RequirePackage[framemethod=default]{mdframed} % Required for creating the theorem, definition, exercise and corollary boxes
  169.  
  170. % Theorem box
  171. \newmdenv[skipabove=7pt,
  172. skipbelow=7pt,
  173. backgroundcolor=black!5,
  174. linecolor=ocre,
  175. innerleftmargin=5pt,
  176. innerrightmargin=5pt,
  177. innertopmargin=5pt,
  178. leftmargin=0cm,
  179. rightmargin=0cm,
  180. innerbottommargin=5pt]{tBox}
  181.  
  182. % Exercise box
  183. \newmdenv[skipabove=7pt,
  184. skipbelow=7pt,
  185. rightline=false,
  186. leftline=true,
  187. topline=false,
  188. bottomline=false,
  189. %backgroundcolor=lightblue4!10,
  190. %linecolor=lightblue4,
  191. innerleftmargin=5pt,
  192. innerrightmargin=5pt,
  193. innertopmargin=5pt,
  194. innerbottommargin=5pt,
  195. leftmargin=0cm,
  196. rightmargin=0cm,
  197. linewidth=0pt]{eBox} % Ήταν linewidth=4pt]{eBox}
  198.  
  199. % Definition box
  200. \newmdenv[skipabove=7pt,
  201. skipbelow=7pt,
  202. rightline=false,
  203. leftline=true,
  204. topline=false,
  205. bottomline=false,
  206. linecolor=ocre,
  207. innerleftmargin=5pt,
  208. innerrightmargin=5pt,
  209. innertopmargin=0pt,
  210. leftmargin=0cm,
  211. rightmargin=0cm,
  212. linewidth=4pt,
  213. innerbottommargin=0pt]{dBox}
  214.  
  215. % Corollary box
  216. \newmdenv[skipabove=7pt,
  217. skipbelow=7pt,
  218. rightline=false,
  219. leftline=true,
  220. topline=false,
  221. bottomline=false,
  222. linecolor=gray,
  223. backgroundcolor=black!5,
  224. innerleftmargin=5pt,
  225. innerrightmargin=5pt,
  226. innertopmargin=5pt,
  227. leftmargin=0cm,
  228. rightmargin=0cm,
  229. linewidth=4pt,
  230. innerbottommargin=5pt]{cBox}
  231.  
  232. % Creates an environment for each type of theorem and assigns it a theorem text style from the "Theorem Styles" section above and a colored box from above
  233. \newenvironment{theorem}{\begin{tBox}\begin{theoremeT}}{\end{theoremeT}\end{tBox}}
  234. \newenvironment{exercise}{\begin{eBox}\begin{exerciseT}}{\end{exerciseT}\end{eBox}}
  235.  
  236. \newenvironment{definition}{\begin{dBox}\begin{definitionT}}{\end{definitionT}\end{dBox}}
  237. \newenvironment{example}{\begin{exampleT}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{exampleT}}
  238. \newenvironment{corollary}{\begin{cBox}\begin{corollaryT}}{\end{corollaryT}\end{cBox}}

User avatar
Stefan Kottwitz
Site Admin
Posts: 8522
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Thu Oct 26, 2017 5:42 pm

The Greek font is Times New Roman or Myriad Pro? Sure that it's not another font and Times or Myriad Pro is used for English?

Just seeing the structure.tex doesn't let me reproduce and test the problem. No greek text here.

Stefan
Site admin

bstex
Posts: 27
Joined: Mon Oct 23, 2017 10:22 am

Postby bstex » Thu Oct 26, 2017 5:49 pm

Hope this helps now:

  1. \documentclass[12pt,a4paper,fleqn]{book} % Default font size and left-justified equations
  2.  
  3. \input{structure} % Insert the commands.tex file which contains the majority of the structure behind the template
  4.  
  5. \begin{document}
  6.  
  7. \chapter{Chatper 1}
  8.  
  9. \section*{Example 1}\index{Paragraphs of Text}
  10.  
  11. \section*{Exercises}\index{Exercises}
  12.  
  13. \begin{exercise}
  14. Λορεμ ιπσθμ δολορ σιτ αμετ, θσθ εξ μινιμ ιμπετθσ cομπλεcτιτθρ, θτ vιξ νοvθμ ιγνοτα αργθμεντθμ. Ετ ηισ νθλλαμ φορενσιβθσ. Vισ ετ σολθμ ηαβεμθσ σιμιλιqθε, ασσθμ μθcιθσ γραεcι ηισ ει. Ορνατθσ μεντιτθμ εθμ θτ. Ενιμ απειριαν περσεcθτι ει σιτ, ει εοσ ηινc νομινατι cονcεπταμ.Cθ μθτατ γραεcισ δελιcατα μει, μθνδι ριδενσ ρεcθσαβο νε ναμ. Νο cιvιβθσ σcριπιτ ηισ. Τε ιθσ παθλο τινcιδθντ αππελλαντθρ, φεθγαιτ ρατιονιβθσ vιμ ιν. Ιν περ jθστο cηορο λεγενδοσ, οδιο vιταε μενανδρι μελ νε. Οπορτεατ σενσιβθσ πρινcιπεσ νο πρι, ριδενσ νεγλεγεντθρ τε vιξ. Σεδ ατ αεqθε ελιγενδι δισσεντιασ. Μελ νο αμετ πθτεντ. Ορνατθσ μεντιτθμ εθμ θτ. Ενιμ απειριαν περσεcθτι ει σιτ, ει εοσ ηινc νομινατι cονcεπταμ.Cθ μθτατ γραεcισ δελιcατα μει, μθνδι ριδενσ ρεcθσαβο νε ναμ.
  15.  
  16. \end{exercise}
  17.  
  18. \end{document}

User avatar
Stefan Kottwitz
Site Admin
Posts: 8522
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Thu Oct 26, 2017 5:59 pm

No, it doesn't. Did you test it?
Please test your code and ensure that it shows Greek and the problem. Even if I fix it (defining ocre color because of an error...) I get this:

no-greek.png
no-greek.png (12.96 KiB) Viewed 189 times


Stefan
Site admin

bstex
Posts: 27
Joined: Mon Oct 23, 2017 10:22 am

Postby bstex » Thu Oct 26, 2017 6:05 pm

Yes, my .pdf file shows greek text correctly. Maybe you don't have the "Myriad Pro" font on your computer. :?

User avatar
Stefan Kottwitz
Site Admin
Posts: 8522
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Thu Oct 26, 2017 6:50 pm

Ok, it took another structure.tex from the template. Now I copied in yours. You could make working on it easier by post in self-contained examples, that just need to be compiled, instead of posting several snippets to be combined, and I still had to fix errors before testing (lightblue4 undefined, xcolor option clash).

Using polyglossia helps:

  1. \usepackage{polyglossia}
  2. \setotherlanguage{greek}
  3. \setmainlanguage{english}
  4. ...
  5. \begin{exercise}
  6. \foreignlanguage{greek}{Λορεμ ιπσθμ ...}
  7. \end{exercise}


Stefan
Site admin

bstex
Posts: 27
Joined: Mon Oct 23, 2017 10:22 am

Postby bstex » Thu Oct 26, 2017 7:04 pm

I'm really sorry for the inconvenience. I just removed some text that I thought wasn't necessary...
Well, I have mixed text (english and greek) on my book, even in the same sentences.
So, polyglossia will not be so useful for me. :cry:

User avatar
Stefan Kottwitz
Site Admin
Posts: 8522
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Thu Oct 26, 2017 7:19 pm

But this works, just use \foreignlanguage{greek}{...} to switch to greek and otherwise use English. No problem mixing it. You can also define yourself a macro with shorter name, for easier typing.

  1. \newcommand{\gr}[1]{\foreignlanguage{greek}{#1}}
  2.  
  3. ... english text \gr{Λορεμ ιπσθμ...} more english text ...


Stefan
Site admin


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 5 guests