The solution posted here Scale (resize) large images (graphics) that exceed page margins works great. Just to summarise, Dave Jarvis suggested
\usepackage{graphicx}
% Determine if the image is too wide for the page.
\makeatletter
\def\ScaleIfNeeded{%
\ifdim\Gin@nat@width>\linewidth
\linewidth
\else
\Gin@nat@width
\fi
}
\makeatother
% Resize figures that are too wide for the page.
\let\oldincludegraphics\includegraphics
\renewcommand\includegraphics[2][]{%
\oldincludegraphics[width=\ScaleIfNeeded]{#2}
}
but unfortunately this breaks any scaling you apply in Lyx to an image. e.g. I have an image resized as so
\includegraphics[scale=0.5]{nicecats}
My scaling of 0.5 gets removed by the macro suggested in the solution above. I'm wondering if there is a way to have the macro apply any user specified scaling first and then check the width? Or perhaps check for any pre-specified scaling and if it exists do not resize. Many thanks.
\makeatletter...\makeatotherLyX does it already for you if it is in the user part of the preamble. – Mar 02 '11 at 14:14