LaTeX Notes
Installing LaTeX in Ubuntu
sudo apt update sudo apt upgrade sudo apt install texlive sudo apt install texlive-lang-cjk texlive-luatex sudo apt install xdvik-ja sudo apt install gv sudo apt install texlive-fonts-recommended texlive-fonts-extra sudo apt install texlive-publishers sudo apt install texlive-science sudo apt install texlive-extra-utils sudo apt install epstoolYou should also use IPAex fonts for Japanese fonts (I think the default font has strange spacing between characters and spaces before and after parentheses.)
sudo kanji-config-updmap-sys ipaexHowever, if you set this up, the text will be garbled when creating pdfs via dvips.
sudo cjk-gs-integrate --link-texmf --force
View dvi files
For English files, evince or okular is sufficient, but for Japanese files, install xdvik-ja and view them from xdvi.Paper landscape orientation in xdvi (landscape)
xdvi -paper a4r hoge.dvi
Creating a partial pdf from dvi
dvipdfmx -o filename.pdf -s pages file.dvi
graphicx options should be specified according to how you compile and the file extension you want to view
dvips to viewing ps files using dvips
dvipdfmx to view pdf files using dvipdfmx
pdftex to view pdf files using pdflatex
xdvi to view dvi files using xdvi
Font size
Specify | 10pt | 11pt | 12pt |
---|---|---|---|
\tiny | 5pt | 6pt | 6pt |
\scriptsize | 7pt | 8pt | 8pt |
\footnotesizesize | 8pt | 9pt | 10pt |
\small | 9pt | 10pt | 11pt |
\normalsize | 10pt | 11pt | 12pt |
\large | 12pt | 12pt | 14pt |
\Large | 14pt | 14pt | 17pt |
\LARGE | 17pt | 17pt | 20pt |
\huge | 20pt | 20pt | 25pt |
\Huge | 25pt | 25pt | 25pt |
Set a normal-looking font (Takao font) via dvipdfmx
The pdf created by dvipdfm has all Japanese characters in Gothic.To avoid this, set Takao font.cd /usr/share/texmf/fonts/ sudo mkdir truetype cd truetype sudo ln -s /usr/share/fonts/truetype/takao-mincho/ takao-mincho sudo ln -s /usr/share/fonts/truetype/takao-gothic/ takao-gothic sudo mktexlsrCreate a file named Takao.map in /etc/texmf/dvipdfmx/ and copy the contents
rml H TakaoMincho.ttf gbm H TakaoGothic.ttf rmlv V TakaoMincho.ttf gbmv V TakaoGothic.ttf rml-jis H TakaoMincho.ttf gbm-jis H TakaoGothic.ttfTo actually use the font
dvipdfmx -f takao.map hoge.dvi
Changing the margins
The default margins are difficult to set; the geometry package makes it easier.\usepackage{geometry} \geometry{left=2cm,right=2cm,top=2.5cm,bottom=2.5cm}
Narrow line spacing in itemize and enumerate
\begin{itemize} \setlength{\parskip}{0pt} \setlength{\itemsep}{0pt} \item hoge \end{itemize}
Maybe we should stop bothering with lualatex
Using lualatex, we don't have to worry about strange behavior around dvi and eps. The pros are that it creates pdf directly without going through dvi or ps, and that you can use pdf, png, jpg for figures. The disadvantages are that compilation is a bit heavy and error messages are hard to read.\documentclass{ltjsarticle} \usepackage{luatexja} \usepackage[ipaex]{luatexja-preset}However, pdflatex is better for English text (it does not have the drawbacks of luatex above). If you use pdflatex for Japanese text, the handling of spaces is a bit tricky.
Using cmbright, kanjifamilydefault, and amsmath in lualatex
Apparently the order of loading in usepackage is important\documentclass{ltjsarticle} \usepackage{cmbright} \usepackage{luatexja} \usepackage[ipaex]{luatexja-preset} \renewcommand{\kanjifamilydafault}{\gtdefault} \usepackage{amsmath,amssymb}
Multi-line formula environment
Here (Jpn) was very helpful. equnarray is deprecatedBasic (with formula numbers)
\begin{align} \end{align}& for positioning. I heard that you can use alignat if you use multiple &'s, but I don't have much oppotunity to do so, so I omitted it.
No formula number
\begin{align*} \end{align*}
Only one formula number in multiple lines
\begin{align} \begin{aligned} \end{aligned} \end{align}If you use multiple &, it is said to be better to use alignedat.
Centered aligned formula
\begin{gather} \end{gather}If you use gather* instead of gather, the formula number will be lost.
Put only one formula number in a centered formula
\begin{align} \begin{gathered} \end{gathered} \end{align}