# Pandoc 導入

## Pandoc 導入

## Install

```
$ brew install pandoc
$ brew cask install mactex
```

zshを使用しているため、.zshrc に以下を追記

```
PATH=/usr/local/texlive/2019/bin/x86_64-darwin/:$PATH
```

変更内容を読み込む

```
$ source ~/.zshrc
```

以下のように実行

```
$ pandoc *.md -o sample.pdf --latex-engine=xelatex -V documentclass=bxjsarticle -V classoption=pandoc
```

### Error

#### pandoc: pdflatex not found. pdflatex is needed for pdf output.

Pandocを実行すると以下のエラー

```
$ pandoc *.md -o sample.pdf
pandoc: pdflatex not found. pdflatex is needed for pdf output.
```

Pandocがpdflatexに依存していて、これがインストールされていないかららしい

```
$ pdflatex -v
zsh: command not found: pdflatex
```

mactex をbrewでインストール

```
$ brew cask install mactex
```

**参考 <https://superuser.com/questions/1038612/where-do-i-get-the-pdflatex-program-for-mac>**

#### command not found: pdflatex

```
$ pdflatex -v
zsh: command not found: pdflatex
```

パスを設定で実行できるようになった

```
$ pdflatex -v                                          
pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019)
kpathsea version 6.3.1
Copyright 2019 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.36; using libpng 1.6.36
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.01
```

#### ! Package inputenc Error: Unicode character は (U+306F)

以下実行で上記エラー文

```
$ pandoc *.md -o sample.pdf
```

指示文どおりに以下のオプションで解消

```
Try running pandoc with --latex-engine=xelatex.
```

#### ! Undefined control sequence.

以下のエラーはエスケープで解消

```
$ pandoc *.md -o sample.pdf --latex-engine=xelatex
! Undefined control sequence.
&lt;argument&gt; \n 

l.935 エラー &amp; - &amp; &#x60;&#x60;-Error message\r\n
```

#### 日本語が表示されない

`-V documentclass=bxjsarticle -V classoption=pandoc` オプションを追加で解消

```
$ pandoc chapter1.md -o sample.pdf --latex-engine=xelatex -V documentclass=bxjsarticle -V classoption=pandoc
```

**参考 <https://qiita.com/sky\\_y/items/15bf7737f4b37da50372>**

#### ! Text line contains an invalid character.

一回削除して同じ文章を打ち直すと解消

### Reference

* Pandoc Manual
  * <https://pandoc.org/MANUAL.html>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hayashier.gitbook.io/article/others/pandoc-get-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
