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.

captionresp.subcaptionpackage 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