19

Here is my document :

\documentclass[12pt]{book}

% must-have packages
\usepackage[turkish]{babel}
\usepackage[utf8]{inputenc} % This package will support Turkish chars
% must-have packages

\usepackage[a4paper,left=2.5cm,right=2cm]{geometry}
\usepackage{graphicx}
\usepackage{listings}

% settings
\setcounter{secnumdepth}{0}
% settings

\begin{document}

\framebox{\includegraphics[scale=0.5]{./images/image_3.png}}

\end{document}

When I try to build a pdf out of this file I received bunch of errors. here is one of them :

Missing \endcsname inserted ...graphics[scale=0.5]{./images/image_3.png}}

When I remove the babel package, it runs smoothly. Even when I change the language to another language, it runs as well.

What is happening here?

tugberk
  • 4,177
  • 7
  • 25
  • 26
  • Just out of curiosity, can you please include \usepackage{pgf} and then try to use \pgfimage[height=3cm]{./images/image_3} . I wonder if the active character problem propagates. – percusse Oct 20 '11 at 19:29

2 Answers2

20

I believed that this problem had been solved, but it seems not.

Since you can input directly Turkish specific characters as Unicode, you should not need the = shortcuts; so

\begin{document}
\shorthandoff{=}

will cure the problem. In case you really need the shortcuts with =, the unique way seems to be to say

\shorthandoff{=}

before all \includegraphics commands and \shorthandon{=} again after them.

egreg
  • 1,121,712
  • 1
    The problem is still present as of TeXLive 2016. I really wonder why it has not been fixed. – Vesnog May 18 '17 at 21:18
  • 1
    @Vesnog I don't know why. – egreg May 18 '17 at 21:22
  • Yet the problem seems to affect bibliography (biblatex) in XeTex and I get errors like:

    Extended mathchar used as mathchar (6300214). \initiate@active@char{:}

    For bibliography

    Package keyval Error: hash=dde4eb9b1037974a732fc2c98a9f94b4 undefined. ^^I\printbibliography[heading=bibliography]

    – Vesnog May 18 '17 at 22:18
  • What problems did you find using this solution? The manual explains another possibility: “The = shorthand is potentially dangerous. You can deactivate with the babel option shorthands or with \shorthandoff: \usepackage[turkish,shorthands=:!]{babel}”. – Javier Bezos May 19 '17 at 17:39
  • @JavierBezos The shorthand is dangerous, but if it exists there should be a reason. Besides, setting shorthands=<whatever> requires knowing all shorthands to keep and this might get complicated with several active languages. So, no: I don't consider it a solution. – egreg May 19 '17 at 17:43
  • @egreg The original author added this shorthand to follow a typographical convention in Turkish. Well, definitely I wouldn't add it, but it's a legitimate use of a shorthand, and a documented one, too. And you are right in that shorthands requires knowing all shorthands in the document, but that's the point (activate only those you actually know, need and use). Very likely, the default should be 'no shorthands at all', but changing it is not that easy! – Javier Bezos May 22 '17 at 07:18
  • @egreg Is this a problem specific to Turkish? Which package/repo I should report for an issue/bug? – berkus Jan 30 '19 at 17:54
  • @MSH This is about babel, not polyglossia. And, specifically, babel for Turkish. Are you sure you linked the right post? – egreg Feb 26 '24 at 21:45
  • @MSH I can't understand what you want to point out, sorry. – egreg Feb 26 '24 at 22:33
2

Please check the answers on this question: \newgeometry doesn't work with Turkish babel package. One answer by @karlkoeller gives an automatic way of switching the shorthand off before \includegraphics then on again after it.

Sinan
  • 295