With the Python document creation tool "Sphinx", you can output in pdf format in addition to html. This entry describes the procedure to output in pdf format.
--How to output a document in pdf format with Sphinx on macOS
--How to install Sphinx * Since the introduction method was introduced in the past entry, please see here. --How to output on other than macOS --Internal mechanism until Sphinx outputs in pdf format
--Installing python3 system --Sphinx 1.5 or above must be installed --You have the latest homebrew installed - When executing sphinx-quickstart of Sphinx, separate "source" directory and "build" directory </ font>
Reference (sphinx-If you answer the question asked when executing quickstart as follows, the directory will be separated. )
#English edition
$ sphinx-quickstart
> Separate source and build directories (y/N) [n]:y
#Japanese version
$ sphinx-quickstart
>Separate source directory and build directory (y/ n) [n]:y
$ python -V
Python 3.7.4
$ pip show sphinx
Name: Sphinx
Version: 2.4.4
(The following is omitted)
$ brew --version
Homebrew 2.2.11
(The following is omitted)
Sphinx can output reStructuredText in pdf format via a format called TeX (LaTeX to be exact).
Type the following command to build a TeX environment on macOS.
"Break cask install mactex-no-gui" takes a lot of time. By the way, it took about 6 hours in my environment.
$ brew cask install mactex-no-gui
The next "sudo tlmgr update --self --all" Depending on your environment, you may get the error "sudo tlmgr command not found". In that case, close the terminal, reopen it, and then try typing the command.
By the way, this command also takes time. It took about 2 hours in my environment.
$ sudo tlmgr update --self --all
Open conf.py under the "source" directory, change / add as follows, and save.
#language part'ja'Change to
language = 'ja'
#Add the following line to the end of the file
latex_docclass = {'manual': 'jsbook'}
If you execute the following command in the directory where the Makefile is located, pdf will be created in "build / latex".
$ make latefpdf
Recommended Posts