modifying MMD compilation for figures to Latex

Hi, I am trying to create a custom format template to export my project to latex.
While compiling with MMD, I noticed that the figures are comprised within the standard markup

\includegraphics[width=400pt,height=300pt]{Figure1.jpg}

But I would like to be able to constrain the size to something more convenient for latex layouts such as:

\includegraphics[width=0.75\textwidth]{Figure1.jpg}

Is there a way to customize this part of the generated markup somewhere in Scrivener?
Thanks

There are two ways of going about this, one from the editing side and the other using scripting in the compiler settings:

  1. Firstly, you have the option to use your own Markdown image syntax if you need to—custom sizes are one of the reasons why you might want to do that. The technique is detailed in the user manual PDF, under §21.4.2, subheading Referencing Images with Document Links, pg. 530. You can take advantage of Scrivener’s compile automation—exporting the image into the output folder and all of that—but maintain full control over the syntax.

    Only thing is, I don’t know if MMD actually supports what you’re trying to do! You’ll have to look into its documentation a bit—with a quick test of my own, supplying what you want as the image size in MMD syntax does not work. It tries to approach things in a language agnostic fashion, so putting stuff like “\pagewidth” into an area that might need to be used by CSS (for example) is generally avoided.

  2. Post-compile scripting. There are multiple ways of doing that—you can change what Scrivener compiles into an .md file before MMD is used to generate a .tex file from it, or you can change the .tex file after it is produced. If you want an example of both, have a look at the support materials provided by the official user manual project. To produce this PDF, I have to run several different modifications, some before and some after .tex conversion. The script itself is Ruby, but you can use whatever you prefer—this is all run through the shell for you. For simple stuff you could probably just get away with a sed or Perl oneliner or two.

Post-processing is documented in §24.22, Processing.


Moderator Note: moved to the MultiMarkdown & LaTeX board; you were posting in an area meant for sharing tips.