I want the images I'm using that exceed the page's text width to be scaled down to half the text width. Images that aren't wider than the text width don't need to be scaled. I have one markdown document that I'm converting to both html and pdf using pandoc.
The following code is in the preamble.
\usepackage{graphicx}
\makeatletter
\def\maxwidth{
\ifdim\Gin@nat@width>\linewidth
\linewidth
\else
\Gin@nat@width
\fi}
\makeatother
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}
What syntax do I use to have maxwidth = x * \linewidth where x = .5 (or some other number)? This is the 5th line in code block.
