1

I have tried to change the language of my article by adding the following lines to the preamble:

\usepackage[greek,english]{babel}
\selectlanguage{greek}

In most of the cases seems to work fine. But when I add captions at the sub figures I am getting the following error:

l.308       \caption{*somecaption* }
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

LaTeX Info: Redefining \anw@print on input line 308.
LaTeX Info: Redefining \anw@print on input line 308.
LaTeX Info: Redefining \anw@print on input line 308.
LaTeX Info: Redefining \anw@print on input line 308.
File: *somepath* Graphic file (type QTm)
<use  "*somepath*" >
./Section5_Results.tex:313: Undefined control sequence.
 \greeknumeral #1->\let \@numer@lsign 
                                 \numer@lsign \let \numer@lsign   \anwtono...

Code example:

 \begin{figure}[H]
\centering
\begin{subfigure}[b]{0.4\textwidth}
  \includegraphics[width=\textwidth]{*somepath*}
  \caption{*somecaption*}
\end{subfigure}
~
\begin{subfigure}[b]{0.4\textwidth}
  \includegraphics[width=\textwidth]{*somepath*}
  \caption{*somecaption*} 
\end{subfigure}
\caption{*somecaption*}
\end{figure}

EDIT 1

I create a sample of my code in order to reproduce the problem but with no luck. In addition, noticed that I should move the \selectlanguage{greek} from the preamble to the "main body" (right after \begin{document}). After that, I'm getting the same following error in both documents:

./latex_example.tex:33: LaTeX Error: Command \nobreakspace unavailable in    encoding LGR.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...                                              

l.33 ... είναι μια επικεφαλίδα}

The sample code:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[greek,english]{babel}
\usepackage[LGR,T1]{fontenc}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{xgreek}
\usepackage{float}
\usepackage{graphicx}
\usepackage[cm-default]{fontspec}


\begin{document}
\selectlanguage{greek}
% \selectlanguage{english} %This works nicely

\today

\begin{figure}[H]
  \centering
  \begin{subfigure}[b]{0.4\textwidth}
    \includegraphics[width=\textwidth]{maxresdefault.jpg}
    \subcaption{Αυτό είναι μια υπο-επικεφαλίδα}
    % \subcaption{This works nicely}
  \end{subfigure}
  ~
  \begin{subfigure}[b]{0.4\textwidth}
    \includegraphics[width=\textwidth]{maxresdefault.jpg}
    \subcaption{Αυτό είναι μια υπο-επικεφαλίδα}
    % \subcaption{This works nicely}
  \end{subfigure}
  \caption{Αυτό είναι μια επικεφαλίδα}
  % \caption{This works nicely}
\end{figure}

\end{document}

EDIT 2

@egreg Tend me to update the TeX and replace the \usepackage{fontenc} with \usepackage{fontspec} . I followed this guide in order to update the TeX version. I used the exact same code with @egreg and now I am getting a completely diferrent error, Here's the whole log file:

>xelatex latex_example.tex 
      This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./latex_example.tex
LaTeX2e <2018-04-01> patch level 5
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/babel.sty
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/switch.def)
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel-english/english.ldf
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/babel.def
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/xebabel.def
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/txtbabel.def))))
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel-greek/greek.ldf
(/usr/local/texlive/2018/texmf-dist/tex/latex/greek-fontenc/lgrenc.def
(/usr/local/texlive/2018/texmf-dist/tex/latex/greek-fontenc/greek-fontenc.def))
)) (/usr/local/texlive/2018/texmf-dist/tex/latex/base/inputenc.sty

Package inputenc Warning: inputenc package ignored with utf8 based engines.

) (/home/manos/texmf/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def))
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/home/manos/texmf/tex/latex/fontspec/fontspec-xetex.sty
*************************************************
* fontspec warning: "cm-default-obsolete"
* 
* The "cm-default" package option is obsolete.
*************************************************
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/euenc/eu1enc.def)
(/usr/local/texlive/2018/texmf-dist/tex/latex/euenc/eu1lmr.fd))
(/home/manos/texmf/tex/xelatex/xunicode/xunicode.sty
*** you should *not* be loading the inputenc package
*** XeTeX expects the source to be in UTF8 encoding
*** some features of other encodings may conflict, resulting in poor output.
(/usr/local/texlive/2018/texmf-dist/tex/latex/tipa/t3enc.def
(/usr/local/texlive/2018/texmf-dist/tex/latex/euenc/eu1lmss.fd))
(/usr/local/texlive/2018/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2018/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2018/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2018/texmf-dist/tex/latex/graphics-def/xetex.def))))
Runaway argument?
{\dim_set:Nn ##1{\fontdimen ##2##3}\dim_compare:nNnT ##1={0pt}{\settoheight \ET
C.
! Forbidden control sequence found while scanning use of \__cs_generate_from_si
gnature:nnNNNn.
<inserted text> 
                \par 
l.1767       \int_case:nnn
                           #2
? 
! Undefined control sequence.
<argument> \LaTeX3 error: 
                           The deprecated command '\int_case:nnn' has been o...
l.1767       \int_case:nnn
                           #2
? 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "kernel/deprecated-command"
! 
! The deprecated command '\int_case:nnn' has been or will be removed on
! 2015-07-14. Use instead '\int_case:nnF '.
! 
! See the LaTeX3 documentation for further information.
! 
! Type <return> to continue.
!...............................................  

l.1767       \int_case:nnn
                           #2
? 
! You can't use `macro parameter character #' in vertical mode.
l.1767       \int_case:nnn #
                            2
? 

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.1767       \int_case:nnn #2

? 
! Too many }'s.
l.1772      }

? 
! Too many }'s.
l.1773    }

? 
! Too many }'s.
l.1774  }

? 
! Undefined control sequence.
<argument> \LaTeX3 error: 
                           The deprecated command '\luatex_if_engine:T' has ...
l.2053 \luatex_if_engine:T

? 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "kernel/deprecated-command"
! 
! The deprecated command '\luatex_if_engine:T' has been or will be removed on
! 2017-01-01. Use instead '\sys_if_engine_luatex:T '.
! 
! See the LaTeX3 documentation for further information.
! 
! Type <return> to continue.
!...............................................  

l.2053 \luatex_if_engine:T

? 
(/home/manos/texmf/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2018/texmf-dist/tex/latex/caption/caption.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/caption/caption3.sty))
(/usr/local/texlive/2018/texmf-dist/tex/latex/caption/subcaption.sty)
(/usr/local/texlive/2018/texmf-dist/tex/xelatex/xgreek/xgreek.sty
Package `xgreek' version 3.0.1 by Apostolos Syropoulos)
Overfull \hbox (1141.06079pt too wide) in paragraph at lines 1767--10
[]\EU1/lmr/m/n/10 25x8X?                                                       



(./latex_example.aux)
(/usr/local/texlive/2018/texmf-dist/tex/latex/cbfonts-fd/lgrcmr.fd)
(/usr/local/texlive/2018/texmf-dist/tex/latex/tipa/t3cmr.fd)

LaTeX Font Warning: Font shape `LGR/CMUSerif(0)/m/n' undefined
(Font)              using `LGR/cmr/m/n' instead on input line 13.

*** you should *not* be loading the inputenc package
*** XeTeX expects the source to be in UTF8 encoding
*** some features of other encodings may conflict, resulting in poor output.

! LaTeX Error: Command \nobreakspace unavailable in encoding LGR.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.27   \caption{Αυτό είναι μια επικεφαλίδα}

? 

! LaTeX Error: Command \nobreakspace unavailable in encoding LGR.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.27   \caption{Αυτό είναι μια επικεφαλίδα}

? 

! LaTeX Error: Command \nobreakspace unavailable in encoding LGR.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.27   \caption{Αυτό είναι μια επικεφαλίδα}

? 

! LaTeX Error: Command \nobreakspace unavailable in encoding LGR.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.27   \caption{Αυτό είναι μια επικεφαλίδα}

? 
[1] (./latex_example.aux)

LaTeX Font Warning: Some font shapes were not available, defaults substituted.

 )
Output written on latex_example.pdf (1 page).
Transcript written on latex_example.log.

Thank you in advance.

  • I would like to have a tiny but complete document for reproducing this problem at my computer. BTW: What TeX engine are you using? pdfLaTeX or luaLaTeX? –  Sep 28 '18 at 18:04
  • I am using the xetex engine. I'll compose a mini sample as soon as possible. – Manos Kirtas Sep 28 '18 at 18:32
  • That would be kind. I tried reproducing the problem using your code snippets, but without success. If the caption resp. subcaption package is your problem I would like to fix that (I am the maintainer of them), but I need the problem to be reproducible on my machine. –  Sep 29 '18 at 07:20
  • @AxelSommerfeldt I tried to reproduce the problem with no luck in the sample code (more described above). – Manos Kirtas Oct 01 '18 at 06:14

1 Answers1

3

You don't want to load the LGR encoding in any case, with a recent TeX distribution. Even less when you use XeLaTeX, where it is actually wrong to load it. Loading xgreek is optional (and I don't recommend it).

Most important is that you need a main font supporting Greek, which the default Latin Modern doesn't.

\documentclass{article}

\usepackage[main=greek,english]{babel}
\usepackage{fontspec}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{xgreek}
\usepackage{graphicx}

\setmainfont{CMU Serif}

\begin{document}

\today

\begin{figure}[htp]
  \centering
  \begin{subfigure}[b]{0.4\textwidth}
    \includegraphics[width=\textwidth]{example-image}
    \subcaption{Αυτό είναι μια υπο-επικεφαλίδα}
  \end{subfigure}
  \begin{subfigure}[b]{0.4\textwidth}
    \includegraphics[width=\textwidth]{example-image}
    \subcaption{Αυτό είναι μια υπο-επικεφαλίδα}
  \end{subfigure}
  \caption{Αυτό είναι μια επικεφαλίδα}
\end{figure}

\end{document}

enter image description here

Choose any font supporting Greek instead of CMU Serif.

If \setmainfont{CMU Serif} doesn't work, because the font is not available to the operating system, the call can be

\setmainfont{cmun}[
  Extension=.otf,
  UprightFont=*rm,
  ItalicFont=*ti,
  BoldFont=*bx,
  BoldItalicFont=*bi,
]
egreg
  • 1,121,712
  • Still getting the same error " LaTeX Font Warning: Font shape LGR/CMUSerif(0)/m/n' undefined (Font) usingLGR/cmr/m/n' instead on input line 2.

    ) (/usr/share/texmf/tex/latex/tipa/t3cmr.fd) <use "example-image.pdf" > <use "example-image.pdf" >

    ./latex_example.tex:24: LaTeX Error: Command \nobreakspace unavailable in encoding LGR.

    See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...

    l.24 ... είναι μια επικεφαλίδα} "

    – Manos Kirtas Oct 03 '18 at 09:48
  • If I remove the "main" from \usepackage[main=greek,english] works nicely but the headers of the caption remain in English. – Manos Kirtas Oct 03 '18 at 09:54
  • @ManosKirtas I suspect you have an outdated TeX distribution; can you please look at it and report? – egreg Oct 03 '18 at 09:58
  • TeX 3.14159265 (TeX Live 2015/Debian) – Manos Kirtas Oct 03 '18 at 10:11
  • @ManosKirtas That's quite old. – egreg Oct 03 '18 at 11:55
  • TeX was updated but the problem remaining. Do you think that error is related with the warning LaTeX Font Warning: Font shape `TU/cmr/m/n' undefined (Font) using `TU/lmr/m/n' instead on input line 105.. Also, just posted the whole log file at the initial post. – Manos Kirtas Oct 04 '18 at 09:51
  • Just notice that I now am getting also another error: ! Undefined control sequence. l.12 \setmainfont {CMU Serif} ? . I think I messed up... – Manos Kirtas Oct 04 '18 at 09:57
  • @ManosKirtas Where's \usepackage{fontspec}? And, as I said, fontenc should not be loaded. – egreg Oct 04 '18 at 09:58