-
-
Notifications
You must be signed in to change notification settings - Fork 2
1.5. Vim for Words
If the final output is the PDF/printout then use LaTeX. If it is web or browser, then use Markdown. More to read
I want to use Vim for making documents in stead of MS Words. By using pandoc to convert a markdown document to a pdf file, I can print it out. First you need to install pandoc. After the installing it, you need to install BasicTeX as well for PDF output. For OSX, you can download BasicTeX.pkg to install it.
# Check if pandoc is installed
$ pandoc --version
If you try to convert a markdown to PDF, you get an error
$ pandoc text1.md -o text1.pdf
pandoc: pdflatex not found. pdflatex is needed for pdf output.
To solve it add PATH for pdflatex.
$ vim .zshrc
export PATH=/usr/texbin
Then reload it.
$ source ~/.zshrc
Try it now.
$ pandoc text1.md -o text1.pdf
There is no way to align images with Markdown. But you can use html markup in md file to align images.
a)
<p align="left">
![alt text](../images/icon48.png)
</p>
b)
<p align="left">
![A picture of a cat](../images/icon48.png)
</p>
I used vim-instant-markdown to see images. I could see images with URL link, but I was not able to see images with relative links. However when I convert to a PDF file, images were shown in the document.
$ pandoc text1.md -o text1.pdf
In order to display mathematics equations, you can use LaTex syntax. You need to add $
in front and at the end of equation.
In line $\frac{1}{4}$ fraction is working.
For instance, this sentence -- which includes the equation $x^{2}+y^{2} = r^{2}$ -- is typeset as
At first, we sample $f(x)$ in the $N$ ($N$ is odd) equidistant points around $x^*$
When you output with pandoc text1md. -o text1.pdf
, margin is set to the default which is too large. You can control the margin with -V
option.
pandoc -V geometry:"top=2cm, bottom=1.5cm, left=1cm, right=1cm" test1.md -o ~/Downloads/test1.pdf
pandoc -V geometry:margin=1in test1.md -o test1.pdf
pandoc -V geometry:"left=3cm, width=10cm" test1.md -o test1.pdf
I tried to use Markdown for PDF. But I found it is hard to acheive what I want by Markdown when you want to print them out. I decided to use LaTeX.
Markdown can't add spaces between lines or images. I can use HTML in markdown. It displays in a browser, but when I convert it through Pandoc, images with HTML are not shown.
Important: The Tables of Content are generated. Any change will be overridden on the next update.
For more information: GitHub Wikifier