\usepackage[turkish]{babel} makes = active. That disturbs key value parser, because they usually assume that the syntax characters = and , have the usual catcode (other=12). The official way is indeed using
\shorthandoff{=}
% stuff that does not expect an active `=', e.g.
\newgeometry{top=1cm}
\shorthandon{=}
Package keyval: \kvsetkeys
A more comfortable way is provided by package kvsetkeys. Its key value parser was written with turkish.ldf in mind. Thus it supports active syntax characters in key value lists. The package defines \kvsetkeys, which can now be
used as direct replacement for \setkeys of package keyval:
\usepackage{keyval,kvsetkeys}
\let\setkeys\kvsetkeys
Package xkeyval
The package directly redefines and extends \setkeys:
\usepackage{xkeyval}
hen active equal signs are supported in key value lists that are processed by \setkeys.
Compatibility
Package xkeyval also changes more things, like the parsing of package and class options, even for packages that do not use or know xkeyval.
Therefore I consider the solution with kvsetkeys less intrusive.
However, both solutions can easily cooperate, even if xkeyval might be loaded by the class or other packages.
The trick is using the first method as early as possible:
\RequirePackage{keyval,kvsetkeys}
\let\setkeys\kvsetkeys
% classes and packages that might load xkeyval
\documentclass{...}
% packages in any order, e.g.
\usepackage{geometry}
\usepackage[turkish]{babel}
\usepackage{graphicx}
\begin{document}
% then the following works without `\shorthandoff{=}`:
\newgeometry{top=1cm}
\includegraphics[width=\linewidth]{...}
Then active equal signs are supported by package kvsetkeys as default or by xkeyval for the case that it is loaded later.
\includegraphicstoo. I mean automatically issue\shorthandoff{=}before\includegraphicsthen\shorthandon{=}after it. I have been searching around with no answers up to now. Should I ask this in a separate question? – Sinan Feb 14 '14 at 09:45