This is most likely because the figure
environment floats, which is not what you're after. For this you have a couple of options:
Add the float
package which provides the H
float specifier, allowing you to use
\usepackage{float}% http://ctan.org/pkg/float
%...
\begin{figure}[H]
%...
\caption[<ToC>]{<regular>}
\end{figure}
stopping the float from moving around.
Add the caption
(or the super-tiny capt-of
) package and wrap your figure inside a minipage
to keep the image and caption together. Use it as follows:
\usepackage{caption}% http://ctan.org/pkg/caption
%\usepackage{capt-of}% http://ctan.org/pkg/capt-of
%...
\noindent\begin{minipage}{\textwidth}
%...
\captionof{figure}[<ToC>]{<regular>}
\end{minipage}
%...
For more information on the placement of figures, see How to influence the position of float environments like figure and table in LaTeX? and Keeping tables/figures close to where they are mentioned.
The above proposals are purely LaTeX-driven.
If you want to manage this within pandoc, consider adding the following to a file called float_adjustment.tex
and place it in your project folder:
\usepackage{float}
\floatplacement{figure}{H}
Then include this file as part of your preamble using the pandoc header
---
title: "A title"
author: "An author"
date: "`r format(Sys.time(), '%d %B %Y')`"
output:
rmarkdown::pdf_document:
fig_caption: yes
includes:
in_header: figure_placement.tex
---
All figures should be forced in-place via the [H]
ERE float specification.
You can easily support custom commands with tex4ht
. Just move declaration of the commands to standalone package, for example mycommands.sty
:
\newcommand{\subchpbreak}{\fancybreak{\rotatebox[origin=c]{90}{\S}}}
and create file with same name, but .4ht
extension, mycommands.4ht
:
\NewConfigure{subchpbreak}{1}
\renewcommand\subchpbreak{\a:subchpbreak}
\Configure{subchpbreak}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class='subchpbreak'>&\#167;</div>}}
\Css{.subchpbreak{font-size:1.2em;}}
To allow configurability, we need to declare some hooks in which will be inserted html code. These hooks are inserted to redefined commands. In this case, we declared new configuration, subchpbreak
with one hook, because your command takes no arguments. For commands one parameter, you would need two hooks, to be inserted before and after the parameter, for two parameters you would need three hooks and so on.
The hook is then inserted to redefined command, the hooks are named as \a:hookname
, b:hookname
, etc. In our case we use only one hook, so it is just \a:subchpbreak
.
The hook is configured with
\Configure{subchpbreak}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class='subchpbreak'>&\#167;</div>}}
we need to use
\ifvmode\IgnorePar\fi\EndP
because <p>
elements are inserted in each paragraph, but we don't want them around our <div>
You can add stuff to the .css
file with the \Css
command.
The resulting html:
<!--l. 15--><p class="noindent" >“Alas, this is a quote,” said the idiot.
</p>
...
</p>
<div class='subchpbreak'>ยง</div>
<!--l. 21--><p class="indent" >
Regarding your problem with fonts, you should use \usepackage[T1]{fontenc}
for best unicode support. When you use paratype
fonts, you may see following message in the terminal output:
--- warning --- Couldn't find font `PTSerif-Regular-tlf-t1.htf'
for each font, .htf
file must exist. I recently provided a solution for Droid sans, in your case you may create following PTSerif-Regular-tlf-t1.htf
file:
.lm-ec
htfcss: PTSerif-Regular-tlf-t1 font-family: 'PT Serif', serif;
see the linked answer about Droid Sans for details. You may need to create similar files also for italic and bold fonts, if you use them.
Best Answer
Well, looking at the eisvogel template, it looks like it typesets blockquotes inside a special
customblockquote
environment defined using the mdframed package: see its documentation.You can define new LaTeX commands for use with pandoc with a
header-includes:
yaml option. (Or in a separate file included with the-H
command line flag.) One option I suppose would be to use such a command to redefine this environment. You'd have to redefine it back to the way the template defines it if you wanted to go back to normalYou could of course define as many such styles as you wanted.
Most likely if I knew more about pandoc filters and templates, there would be a more straightforward way, but this may work well enough for your purposes.