`\input{table.tex}`{=latex}
As you might guess, this new system is a lot more powerful since you can declare the output type that should use the pass-thru. If you compile a document with the above to HTML or ODT, it will be completely ignored in the output.
Precisely. What I do is mark the verbatim text bright red, and then use that menu command to create a character style called “Raw LaTeX”, and go through an apply it to anything else that needs it. Use whatever aesthetic you prefer though.
You don’t need to mess with compile settings unless, like I say, you are creating your own compile Format (the list of things in the left sidebar) from scratch, or using one of the basic ones that isn’t aimed at LaTeX use (such as “Basic MultiMarkdown” or “Default”).
Just keep in mind that the Styles list in the compile format looks for matching names of styles used in the project. That is how we magically add syntax to text that we mark. It’s a very powerful capability worth becoming familiar with as it can mean reducing clutter in the writing space. If you flip through some of the example styles in those formats, you’ll see what I mean—for example the indexing styles can add the indexing syntax around words you highlight.
I am using a custom compile format (among other things, I’m working on project started in the old scrivener). I added my ‘Raw Latex’ style to the styles list but on first try I am still getting the same problem. I see the box ‘treat as raw markup’ – does that need to be ticked? (Trying it now, anyway…)
Did you copy the prefix and suffix fields from one of the other formats? That is necessary otherwise it won’t do anything.
The “raw syntax” checkbox doesn’t do anything unless you’re using the checkbox that converts RTF style formatting to MMD (it is thus a way to type Markdown into such documents as conversion otherwise escapes MMD punctuation).
On to the next (related) thing – this works for inclusion of tables and figures, which pretty much by definition go in their own paragraph. But I was also using HTML comments to use table and figure references, such as:
As shown in table <!--\ref{tab:mytable}-->
These go within a paragraph and indeed within a sentence. When I select just this text to mark it as my ‘raw LaTex’ style, the whole paragraph acquires this style. Is ‘style’ inherently defined for whole paragraphs? Is there way to define this style for just a short chunk of a pragraph?
In that case you’ll probably want a pair of styles, one for whole blocks and another for inline spans (with distinctive names, like “Raw LaTeX Span” or “Raw LaTeX Block”).
You can create a character style by using the same “New Style from Selection” menu command, and making sure to set the Formatting dropdown to “Save Character Attributes” in the style configuration window. It will have a different icon in the style menus and lists, just an ‘a’. Then of course create a compile style matching it (it is important to match character styles with character styles and vice versa).
That aside, I did not realise you were looking to implement whole blocks with the first one. There are two different forms of this Markdown syntax that you can use, the one demonstrated below is safer for large blocks of multiple lines, and the other I already showed you is better for inline markings that won’t span newlines:
```{=latex}
\begin{figure}[htbp]
\centering
\includegraphics[keepaspectratio,width=\textwidth,height=0.75\textheight]{image_name.png}
\caption{The caption of the image}
\end{figure}
So the special bits here are the triple-ticks on their own lines at the beginning and end, and of course the {=latex} marker on the end of the first.
raw_latex_samples.zip (131.7 KB)
The attached project has a couple of working examples, including compile settings, for your reference. Really the only tricky thing here is to make sure that your Prefix and Suffix fields have a newline after and before, respectively, for the block method shown above. For the syntax to be valid they must fall at the start of a line.
By the way, you are aware that MultiMarkdown already does some of the things you are describing? It can generate figures, tables and you can cross-reference to them using more natural syntax to do so. I get if you want custom syntax though.
One last thing:
As shown in table <!--\ref{tab:mytable}-->
This is an example of where maybe using a style just for that is a good idea as this is the kind of thing you’re probably going to be typing in a lot of. We could cut down what you need to type to: “tab:mytable” into the editor, while the compiler, via the prefix and suffix fields, inserts this around the text:
Prefix: `\ref{
Suffix: }`{=latex}
Update (for posterity): figured out that this can be done by applying character style, rather than paragraph style, to the in-line text. One thing I am still confused about @AmberV is the best way to create a new character style. When you create a new style it seems to be a paragraph style by default. I got around this by choosing Style → redefine style from selection and redefining one of the existing character styles, but this seems like a bit of a hack.
Has anything changed with how Scrivener allows raw Latex to be passed through compiling with multimarkdown? I have been using the steps discussed in this thread from over a year ago, but suddenly cannot get this to work on new documents. I have created Raw Latex and Inline Raw Latex styles and added them to the styles window with prefix: and suffix{=latex}. My inclusion of:
\loadFigure{fig:polarization-survey}
renders as
\textbackslash{}loadFigure{fig:polarization-survey}
In the compiled .tex document
Yeah, the forum also uses Markdown, so you have to code block if you want to demonstrate something verbatim like this.
`\loadFigure{fig:polarization-survey}`{=latex}
What went wrong, out of curiosity?