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}