Introduction
In the previous posting, I showed how to prepare for generating various formats of documents using PANDOC. This is a demo post to convert from a markdown format of text to another format of document such as pdf, html, docx, tex, etc..
Writing technical documents.
As in Latex, you create a bib file (bibliography.bib) containing sources which you will cite in writing technical documents and then download a csl file (ieee-with-url.csl) which is an open-source XML-based language that is used for automating the formatting of citations and bibliographies. You need to install pandoc-crossref to refer any figure, table, listing, or equation in the document. Since pandoc-crossref uses the same citation syntax as citeproc, you have to run former before latter.
Sample markdown file (test.md)
---
title: "test"
author: "Panbong Ha"
date: \today
---
\tableofcontents
\newpage
## 글씨체{#sec:sec1}
다음과 같은 글씨체가 지원된다[see [Sec. @sec:sec1]].
- subscript example: test<sub>2<sub>
- superscript example: test<sup>2</sup>
- strike through example: ~~test~~
- empathic example: **test**
- italic example: *test*
- bold italic example: ***test***
- underline example: <u>test</u>
## 열거와 표
There are the followings:
1. first one
2. second one
[Table @tbl:example]는 다음과 같다.[^1]
: Example table. {#tbl:example}
| item1 | item2 | item3 |
|:---:|:---:|:---:|
| 20 | 300 |5 |
| 1 | 50 | 100 |
[^1]: 이 외에도 좌, 우 정렬도 할 수 있다.
## 웹 주소와 그림
하얀 개는 [Fig. @fig:dog]에 보였다.
{#fig:dog}
저의 홈페이지로 오실려면 다음을 클릭하세요
[my hompage](https://panbong.github.io).
Paper reference[@kim_2010_eeprom_mcu]의 예를 보여줍니다.
Book refereence[@ha_2016_systemverilog]의 예를 보여줍니다.
## Block quote and code
블록으로 인용하는 예입니다.
> 첫째 줄.
> 둘째 줄.
다음은 Python 코드의 예입니다[see [Listing @lst:code]].
<div id="lst:code" class="listing">
Listing caption
```{.haskell}
main :: IO ()
main = putStrLn "Hello World!"
```
</div>
## 수식
다음은 수식 [Eq. @eq:eq1]과 [Eq. @eq:eqn2]을 보여준다.
$$1 \times 1 =1$$ {#eq:eq1}
$$1 \div 2 = \frac{1}{2}$$ {#eq:eqn2}
\newpage
## References
Sample biblography file (bibliography.bib)
@article{kim_2010_eeprom_mcu,
author = {Kim, Du-Hwi and Jang, Ji-Hye and Jin, Liyan and Ha, Pan-Bong and Kim, Young-Hee},
month = {12},
pages = {316-324},
title = {Design of an EEPROM for a MCU with the Wide Voltage Range},
doi = {10.5573/jsts.2010.10.4.316},
urldate = {2021-07-28},
volume = {10},
year = {2010},
journal = {JSTS:Journal of Semiconductor Technology and Science}
}
@book{ha_2016_systemverilog,
author = {Ha, Panbong},
month = {03},
publisher = {GS인터비전},
title = {쉽게 배우는 SystemVerilog HDL Programming},
year = {2021}
}
Bash shell scripts converting formats
From a markdown file to a pdf file (md2pdf.sh)
#!/bin/bash
pandoc --filter pandoc-crossref --citeproc --bibliography="bibliography.bib" --csl="ieee-with-url.csl" "$1".md -o "$1".pdf --pdf-engine=xelatex -V mainfont='NanumMyeongjo' -V sansfond='NanumGothic' -V monofont='NanumGothic' --from=markdown+yaml_metadata_block+tex_math_single_backslash+tex_math_dollars+raw_tex --standalone --number-sections
./md2pdf.sh test
From a markdown file to a html file (md2html.sh)
You need to MathJax which is a JavaScript display engine for mathematics that works in all browsers.
#!/bin/bash
pandoc --filter pandoc-crossref --citeproc --bibliography="bibliography.bib" --csl="ieee-with-url.csl" "$1".md -o "$1".html --pdf-engine=xelatex -V mainfont='NanumMyeongjo' -V sansfond='NanumGothic' -V monofont='NanumGothic' --from=markdown+yaml_metadata_block+tex_math_single_backslash+tex_math_dollars+raw_tex --standalone --number-sections --mathjax=https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML --metadata pagetitle="Design" --css=pandoc.css
Click here to see the converted pdf file.
./md2html.sh test
Converted document
Actually the conversions work very well, but a liitle strange things happen in cutting and pasting the html nresult here.
test
0.1 글씨체
다음과 같은 글씨체가 지원된다[see Sec. 1.1].
subscript example: test2</p></li>
superscript example: test2
strike through example:
testempathic example: test
italic example: test
bold italic example: test
</ul>underline example: test
0.2 열거와 표
There are the followings:
- first one
- second one
Table 1는 다음과 같다.1
Table 1: Example table. item1 item2 item3 20 300 5 1 50 100 0.3 웹 주소와 그림
하얀 개는 Fig. 1에 보였다.
저의 홈페이지로 오실려면 다음을 클릭하세요 my hompage.
Paper reference[1]의 예를 보여줍니다. Book refereence[2]의 예를 보여줍니다.
0.4 Block quote and code
블록으로 인용하는 예입니다.
첫째 줄.
둘째 줄.
다음은 Python 코드의 예입니다[see Listing 1].
Listing 1: Listing caption
main :: IO () = putStrLn "Hello World!" main
0.5 수식
다음은 수식 Eq. 1과 Eq. 2을 보여준다.
\[1 \times 1 =1\qquad(1)\]
\[1 \div 2 = \frac{1}{2}\qquad(2)\]
References
[1]D.-H. Kim, J.-H. Jang, L. Jin, P.-B. Ha, and Y.-H. Kim, “Design of an EEPROM for a MCU with the wide voltage range,” JSTS:Journal of Semiconductor Technology and Science, vol. 10, pp. 316–324, Dec. 2010, doi: 10.5573/jsts.2010.10.4.316.[2]P. Ha, 쉽게 배우는 SystemVerilog HDL programming. GS인터비전, 2021.
이 외에도 좌, 우 정렬도 할 수 있다.↩︎