General way
If you want to make a precise control, the generalised way as pointed out by @jpkotta is perhaps a way forward. That is, type M-x compile
and the entire command of pandoc
, including the filename of the buffer (try.md
). I do not know how to set a compilation command per-buffer for a markdown file.
pandoc-mode way
However, in this specifi example (and in a vast majoriy of cases with pandoc), it would be better (easier) to use the native pandoc-mode way; that is, set up the required options first and run the conversion command every time you want. Here is the procedure, based on GNU Emacs Ver.25.3.1 and pandoc-mode Ver.20180122.108.
In pandoc-mode
, you can set the environment via the pandoc-mode option panel, which is invoked by typing C-c /
or M-x pandoc-main-hydra/body
from the buffer you are editing (try.md
in this case). Then, do as follows.
Note the following procedure is based on the command interface. Alternatively, if the tool-bar is available in your Emacs environment, the same thing should be possible via GUI by clicking Pandoc
tab in the tool bar (I don't go in detail). Also, for clarity, I am assuming you return to the main menu by pressing b
(maybe multiple times) after each step, though you may not have to in reality, depending how and what you do.
- Input format: Select it by
I
(Input format) and m
(Markdown).
- It seems this command exits the option panel; so you need to invoke
C-c /
again after this.
- Output format: Select it by
O
(Output format) and l
(LaTeX). There is no PDF option here. See the author's description to find why it is LaTeX. I believe the native pandoc does so, too, internally (you can check it via pandoc --verbose
option).
- (Optional) Output filename: Set it by
o f o YOUR_OUTPUT.pdf[RET]
(Options → Files → Output file). In this specific case, you can skip this, because try.pdf
is the default PDF filename converted from try.md
.
- nb., if you want to cancel it, that is, to set it back to the default, type
o f C-u o
(from the main menu).
Command-line option: To set --variable=subparagraph
, type o w v subparagraph[RET] t[RET]
(Options → General writer options → Variables)
- Run: To generate a PDF, type
p
(or, if it is from the buffer, the sequence is C-c / p
. Alternatviely, via tool bar, navigate "Pandoc" > "Creat PDF")
- nb., again, PDF creation is exceptional; for any other runs of
pandoc
, it is c
(Run Pandoc)
Finally, the command-search path must be correctly set so that pandoc-mode can find the commands pandoc
and pdflatex
(or similar). My .emacs
contains the following lines:
(setq exec-path (append exec-path '("/usr/local/bin")))
(setenv "PATH" (concat (getenv "PATH") ":/Library/TeX/texbin"))
That's it. Hope it works for you.