[Tex/LaTex] ! Missing \endcsname inserted

babelpdfpagesturkish

I have a problem with the package \usepackage{pdfpages} and maybe the reason is
\usepackage[turkish]{babel}. I need to use that package. Can anyone help me, please?

 \documentclass[11pt]{article}
 \usepackage[left=2cm, right=2cm, top=3cm, bottom=3cm]{geometry}

  \usepackage{sectsty}
  \usepackage{amssymb,latexsym,cite}
  \usepackage{pstcol,pstricks,color}
  \usepackage{amsfonts, amsmath}
  \usepackage{graphicx}
  \usepackage{comment}
  \usepackage{pdfpages}
  \usepackage[turkish]{babel}
  \usepackage[utf8]{inputenc}
  \usepackage[T1]{fontenc}
  \usepackage{subcaption}
  \newtheorem{theorem}{Theorem}[section]

  \usepackage{fancyhdr}
  \usepackage{pdfpages}
  \pagestyle{fancy}
  \fancyhf{}
  \rhead{Overleaf}
  \chead{X}
  \fancyfoot[CE,CO]{\leftmark}
  \fancyfoot[LE,RO]{\thepage}
  \renewcommand{\headrulewidth}{2pt}
  \renewcommand{\footrulewidth}{1pt}

  \begin{document}
  \pagenumbering{gobble}
  \title{XYZ}

  \date{}
  \maketitle
  \vspace*{-1.5\baselineskip}



  \section{B}

  \includepdf[pages=-]{putyourpdfhere}

  \end{document}

Best Answer

Your MWE can be further reduced to the following code:

\documentclass[11pt]{article}

\usepackage{pdfpages}
\usepackage[turkish]{babel}

\begin{document}
\section{B}
\includepdf[pages=-]{<document name>}
\end{document}

That still produces the error message Missing \endcsname inserted..

As already discussed here, and here the turkish option of babel makes the = active. To overcome this, you could use the following if you want to keep shorthands active thoroughout the rest of the document.

\documentclass[11pt]{article}

\usepackage{pdfpages}
\usepackage[turkish]{babel}

\begin{document}
\section{B}
\shorthandoff{=}
\includepdf[pages=-]{<document name>}
\shorthandon{=}
\end{document}

If you don't want to use any shorthands throughout the document, you might also be interested in globally turning them off using the shorthands=off option as shown in the following MWE:

\documentclass[11pt]{article}

\usepackage{pdfpages}
\usepackage[turkish,shorthands=off]{babel}

\begin{document}
\section{B}

\includepdf[pages=-]{<document name>}

\end{document}

More information on this topic can also be found in section "1.10 Shorthands" of the babel manual.