Figure Cross-Reference

I’m trying to learn Scrivener and MMD while generating notes for an organic chemistry course I’m teaching in the fall. I can successfully insert images into the text with auto numbering, but I cannot figure out the syntax to cross-reference images. I looked at several other posts related to this and I am still unable to accomplish this. In the attached image, I need the syntax to reference the image “Simplification of linoleic acid” I have embedded in the text (auto numbered Figure 2.2 when I compile MMD --> PDF). In other words, what syntax would I need to use to generate the highlighted text in the attached image?

Thanks.

Image usage for MMD is discussed in the user manual under §22.4.1 (starting on pg. 322, with cross-references in particular being address on pg. 323). Briefly though, the image’s full file name is used as the cross-reference identifier. The filename is whatever you’ve called it in the Binder + it’s extension. Thus, in this case you’ve highlighted here, assuming this is a PNG file, the reference code would be like so.

You may also be interested to know that the Scrivener and Scapple user manuals are written in MultiMarkdown. You can download the .scriv projects for them from our support page. They are thus useful as a reference for how one can use MMD and Scrivener together to produce LaTeX PDFs.

I appreciate the timely response. I did read those pages of the manual as I tried various combinations of MMD syntax to get this working. The cross-reference in question is referring to Simplification of linoleic acid where 19a is a Scrivener link to the .png file in my Research folder. As such, the reference code would be ? Yet, when I compile the document, I’m still getting “??” as opposed to"Figure 2.2".

I apologize if I’m missing something obvious. I installed MMD and LaTeX as described in “Scrivener - MMD 3 - Latex: A beginner’s guide” posted in this forum

I upgraded to MMD 4.2 after reading this earlier post: https://forum.literatureandlatte.com/t/cross-referencing-figures-latex/22403/1

Still no luck…I’ll keep trying…

I’ve been poking about at this one to see what’s going on, and it seems to me there is a vital difference in behaviour with two different ways of putting images in Scrivener for mmd. (Tested with Scrivener 2.4.1, MMD 4.2)

With MMD 3+ I put images in like this:

The first line sets up the insertion and the second line defines the content of the insertion (the underline shows a Scrivener link to the file which sorts out the export).

On compile that gives:

\begin{figure}[htbp] \centering \includegraphics[keepaspectratio,width=200pt,height=0.75\textheight]{BinToSec.png} \caption{A picture} \label{picture} \end{figure}

The cross reference comes out as Figure 0.1.

However, using the syntax:

the compile gives:

\begin{figure}[htbp] \centering \includegraphics[keepaspectratio,width=\textwidth,height=0.75\textheight]{Grumpy.png} \caption{A grumpy badger} \end{figure}

The one thing that doesn’t give is a label:

\label{grumpy.png}

So any cross-reference will fail, because there is no label to pick up. I’d suggest you try the first syntax pattern and see you can get that working.

(Personally I’m going to stick with the first way because it gives me control over the size of my images - without the size definition they come out as wide as the text.)

One other thing to make sure is that you are typesetting at least twice to resolve references. The first time you run LaTeX it creates the internal referencing index, but since this is only done in one linear sweep, the original pointers are not retroactively updated, and will have the (??) placeholder. Running typesetting a second time utilises the index and fills in the placeholders with proper references. A third time will ensure that references remain coherent over a long document, as replacing numerous “(??)” with the longer descriptive labels can cause page shifts to occur (the link will still work, but might drop the user to the wrong spot in the document). If you compile straight to PDF, Scrivener will handle all three typesetting phases for you transparently.

I appreciate the help from you two. Compiling MMD --> PDF with MrGruff’s first syntax worked. Thanks again!