Diagrams don't "stay put" (MMD -> LaTeX -> P

I have a manually managed glossary in my Scrivener document. It is organized hierarchically as follows: Draft ... Glossary (empty document) Entry 1 (document) Entry 2 (document) ... Research Diagrams AccessControlPolicy
Now suppose I have the following text in Entry 1:[code]
blah blah blah

![AccessControlPolicy][AccessControlPolicy]

blah blah blah more stuff

[AccessControlPolicy]: AccessControlPolicy “AccessControlPolicy” width=291px height=56px
[/code]
Here “AccessControlPolicy” is a png file which I want to appear right between the two blah blah lines.

The problem seems to be that the generated tex document doesn’t do anything to ensure the diagram actually ends up there in final PDF document.

In particular, the diagram often “floats” down and appears somewhere between the other glossary entries in the page.

I can understand that this behavior may not be a problem in a long paper where the text just reads “refer to figure 1” but in this case this is terribly confusing because glossary readers don’t read the glossary linearly and instead only skip to one section.

Is this a known issue and is there a way to solve it?

It’s a known issue in that it’s the way that LaTeX works. Remember, LaTeX follows a philosophy that’s sort of akin to “Tell me all the stuff that goes in your document, and let me figure out the best way to lay it out typographically.” It’s not a “What You See Is (Almost) What You Get” editor.

You can google around to figure out how to tweak the resulting LaTeX to try and force placement of an image in a certain place.

What I do instead is use the approach demonstrated in the sample document for Tables and Figures - I simply reference them where appropriate. Then, the user can figure out which image to look at (it will usually be somewhere appropriate, just not always right where you put it in the source.)

The main thing to remember is that there is a big philosophical difference between LaTeX and programs like word, in addition to the enormous quality differences.

I see. As I indicated this isn’t a problem in most places in the document, but this behaviour is at odds with the way the glossary I have is set up.

I’m not familiar with LaTeX but it seems ilc.cnr.it/EAGLES96/layout/node36.html describes one way to deal with it.

Where do you suggest I start if I want to change MultiMarkdown to use this kind of LaTeX?

I see. As I indicated this isn’t a problem in most places in the document, but this behaviour is at odds with the way the glossary I have is set up.

I’m not familiar with LaTeX but it seems ilc.cnr.it/EAGLES96/layout/node36.html describes one way to deal with it.

Where do you suggest I start if I want to change MultiMarkdown to use this kind of LaTeX?

Most of the LaTeX stuff is in xhtml2latex.xslt (all conversion from XHTML to something else is handled by XSLT files.)

xhtml2latex is the core routine, and it is called by other files (e.g. memoir.xslt) that designate a document type.

The image handling is in xhtml2latex, and it’s not too hard to modify.

I think I’ve found a good solution, but I’d like your feedback on it.

Based on what tex.ac.uk/cgi-bin/texfaq2htm … figurehere says it seems the whole problem is the way \begin{figure} works. If the generated LaTex doesn’t use a that, then an image will stay where you put it.

With that in mind I added “support” for an extra option called “nofigure”. The change is trivial:

powerbook.local 102> diff xhtml2latex.xslt xhtml2latex.xslt.orig
735d734
<       <xsl:if test="not(@nofigure)">
750d748
< </xsl:if>
821,823d818
< </xsl:text>
< <xsl:if test="not(@nofigure)">
< <xsl:text>
826d820
< </xsl:if>

With that change, adding the nofigure=1 attribute e.g. [code]

![Overview][Overview]

[Overview]: Overview “Overview” width=392px height=329px nofigure=1

[/code]

will cause this to be generated [code]

\begin{center}
\resizebox{392pt}{329pt}{\includegraphics{Overview.png}}
\end{center}

[/code]
instead of this [code]

\begin{figure}
\caption{Overview}
\label{overview}
\begin{center}
\resizebox{392pt}{329pt}{\includegraphics{Overview.png}}
\end{center}
\end{figure}

[/code]

Without the \begin{figure} the image goes right where I want it to.

Removing the \label{} function will have other consequences - you might want to put that in now to save you from asking that question later on when you can’t link to an image placed this way… :wink:

Test this out some more and let me know if you have trouble with it. I’ll look at it and if it works well, it could be added to the default MMD file.

Thanks for the suggestion,

F-