Trying to insert raw latex following FAQ

I’m trying to get this in my tex output:

\begin{keypoint}
some stuff
\end{keypoint}

So I read the FAQ at fletcherpenney.net/multimarkdown/faq/ and put this in Scrivener:

some stuff

But that gave me nothing in the tex file.

What am I doing wrong? — thanks

hi!

have you tried to put all the latex stuff in HTML comments?

e.g.

kind regards,

pascal

Thanks. I tried that too, nothing shows up in the Tex file.

Yeah, I cannot get this to work either. Perhaps Fletcher removed it from a more recent build and the FAQ was never updated. Have you tried using the clean-text-allow-latex.xslt include rather than clean-text.xslt? The line you need to change is in xhtml2latex.xslt. That will not escape LaTeX special characters, so you’ll have to write in Scrivener as though you were writing in TeXShop when comes to brackets and so forth. Using that XSLT, you can just embed the commands right into the text normally; no need for HTML comments.

If you are writing specifically for LaTeX, that is probably the best way to go for features above what MMD provides. Naturally, it will make a messy document when exporting to other formats, though.

Hmm. I could not find “clean-text.xslt” anywhere in xhtml2latex.xslt. I did find a template named “clean-text”
<xsl:template name=“clean-text”> …

and it looks quite strange to me (even more so than normal xslt :slight_smile: with numerous identical looking invocations of:
<xsl:call-template name=“replace-substring”>
<xsl:with-param name=“original”>
<xsl:call-template name=“replace-substring”>
<xsl:with-param name=“original”>

Edit: those are actually are lots of nested calls to replace-substring, 27 deep. I hate xsl :slight_smile:

Thanks for checking … Any ideas?

Wait, what version of MMD are you using? That clause was removed to a separate file in either b3 or b4 I think. The comment method for including arbitrary LaTeX was added in b5. You might want to check and make sure you are running the latest beta before trying anything else. Once you have that, the line I was referring to in the other post is on line 40 of xhtml2latex.xslt, but you might get comments working simply by upgrading.

[size=80]And yes, I hate XSLT, too. :slight_smile: It feels like a language designed by eight different committees each experimenting with various styles of methamphetamines, and dealing with one another only via disinterested liaisons who spent more time at the pub than passing along messages.[/size]

You mean they used vic-k? That explains a whole lot.

About XSLT not vic-k.

OK, updated multimarkdown and I can now get straight-through Latex. Quoting latex control chars in my normal text will be a bit error-prone, but unless I get the HTML comment thing working, I’ll go with it.

One more question, if you don’t mind. How do I get this into the generated Tex (somewhere before the \begin{document}) ? More XSLT editing? If so I better put that folder under version control !

\newcommand \keypoint[1] { \begin{quote}
\emph{KEY POINT}: #1
\end{quote} }

Thank you so much, Amber!

You are welcome!

Yes, you’ll need to edit the main xhtml2latex.xslt file if you want to add stuff to the preamble. Fortunately, that is fairly easy. The header and intro are located at the bottom of the file (line 1000+) and it is just a raw text entry so it is simple to make modifications. This will change behaviour for all of the LaTeX XSLTs though. If you want to set stuff for a single document, try checking how 6x9book.xslt works. All it does is adjust the way the much larger memoir.xslt works. Duplicate that simple one and change it to include the stuff you need. Then set the LaTeX XSLT meta-data field to use your customised one. Should be golden.

If you want to use html comments to pass raw latex through to your document, the html:body template on line 364 in xhtml2latex.xslt needs to be changed to match comment nodes, in addition to element nodes. Try changing it to this:

<xsl:template match="html:body">
	<xsl:apply-templates select="*|comment()"/>
</xsl:template>

Thank you, whaynes. That works a treat, and I had approximately zero chance of figuring it out myself.

I have my mmd directory under source control now, feel a bit better about changing stuff :slight_smile:

Fletcher, in case you see this … can you confirm that this should (not) be the default behavior?

Thanks!