# Error “Missing \endcsname inserted” when including PDF using \includegraphics

\documentclass[12pt,a4paper]{article}
\usepackage{color}
\usepackage[turkish]{babel}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{graphicx}

%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}
\includegraphics[width=3cm, height=4cm]{2.pdf}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%


The error message is:

Missing \endcsname inserted. \relax l.334 ...udegraphics[width=3cm, height=4cm]{1.jpg}

but, if add only a picture, then it is ok.

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\begin{figure}
\includegraphics[width=3cm, height=4cm]{1.jpg}
\end{figure}

\end{document}


This is ok. But why does the first one give an error message?

• I know that the graphicx package is fantastic, but this is no reason to load it more than once. – samcarter Dec 11 '18 at 10:13
• It is also better to not specify both the width and height of an image, this will distort the image. If you must specify both, add at least keepaspectratio – samcarter Dec 11 '18 at 10:17

By default the turkish language option makes = into an active character, essentially ruining any key=val interface (as they assume = to be a normal character).

The standard method of dealing with this is \shorthandoff{...}:

\documentclass{article}

\usepackage[turkish]{babel}
\usepackage{graphicx}
\begin{document}

\begin{figure}
\shorthandoff{=}
\includegraphics[width=3cm, height=4cm]{example-image}
\end{figure}

\end{document}


Used like this, it temporarily (inside this figure env) deactivates = making it behave normally, thus width=3cm works again.

The documentation for turkish babel (texdoc babel-turkish) mentions that the activation of = is potentially dangerous, and you can use

\usepackage[turkish,shorthands=:!]{babel}


to just active :!, leaving = alone.