Latex - snow-stone/LatexNote GitHub Wiki

latex

workFlow

$ latex myarticle       # LaTeX Warning: There were undefined references.
$ bibtex myarticle
$ latex myarticle       # LaTeX Warning: There were undefined references.
$ latex myarticle       # no more warning
$ pdflatex myarticle    # generate pdf

Installation

Texlive

A full installation of texlive is different from an ordinary one.

$ sudo yum install texlive
$ sudo yum install texlive-*  # much more packages including /usr/share/texlive/texmf-dist/tex/xelatex/xecjk/xecjk.sty

Fonts

Fonts installation : folder 'fonts' at the same level as 'tex'

# texmf is under at $HOME
[texmf]$ tree
.
|-- fonts 
|   `-- truetype
|       `-- chinese
|           `-- simsun.ttf
`-- tex 
    `-- latex
        `-- local
            |-- authblk.sty
            |-- siunitx.sty
            `-- ulem.sty

Texmaker

$ sudo yum install texmaker # here only the editor will be installed as texlive has set compilers and packages ready.

In Equations

make the letter bold and italic.

\usepackage{bm}
...
$ ... \bm{letter or symbol} ... $

write derivative using prime

$ ... f' ...$

latexdiff

May require installation

$ latexdiff draft.tex revision.tex > diff.tex

What do we do when we have missing packages?

Follow the first answer from tex.stackexchange and do the following steps. Take "missing authblk.ins" as example.

  1. Search for package name from site CTAN and download
  2. There is a README introducing how to install for example *.sty. (or *.sty which requires no installation [ex: ulem.sty required by latexdiff], just put it at the right place /home/hluo/texmf/tex/latex/local/)
$ latex authblk.ins

and the authblk.sty will be generated. The question mark is "where to put it". 3. I have on my system a precompiled version of texmaker which is dependent on texlive packages residing at /usr/share/texlive/* which requires administrator permission. You will not want to mess up with original packages (which are not necessarily complete... That's why I am doing this). Take advice from the answer and do step 4 4. Create a directory at $HOME and put the *sty at particularly named subdirectory.

$ kpsewhich -var-value=TEXMFHOME  # Directory name need to be
/home/hluo/texmf
$ mkdir /home/hluo/texmf
$ cd /home/hluo/texmf
$ mkdir -p tex/latex/local/
$ mv authblk.sty /home/hluo/texmf/tex/latex/local/

And that's it (don't need to hash it to the database as the second answer proposes. Because it is a small package). I recompile the *.tex containing authblk and texlive just find the package when it's invoked. See log for clearance

*************************************
* Local config file frenchb.cfg used
*
(/usr/share/texlive/texmf-dist/tex/generic/babel/frenchb.cfg)))
(/usr/share/texlive/texmf-dist/tex/latex/carlisle/scalefnt.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/tools/bm.sty)
(/home/hluo/texmf/tex/latex/local/authblk.sty)                   # this is local
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty))
(./HowPlanesFLy.aux) (/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/share/texlive/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty))
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd)

Latex write in Chinese

solution ctex

Not included in defaut texlive full package

solution CJKutf8 (see also in Latex input French Alphabet)

\documentclass{article}
\usepackage{CJKutf8}
 
\begin{document}
 
\begin{CJK*}{UTF8}{gbsn}  % gkai : this is 楷体
 
\section{前言}
在该第一部分中的一些额外的元素可以被添加。巴贝尔包将采取的翻译服务.

\section{关于数学部分}
在本节中的一些数学会使用数学模型含中文字符显示。
 
\end{CJK*}
 
\vspace{0.5cm} % A white space
 
\noindent
You can also insert Latin text in your document
 
\vspace{0.5cm}
 
\noindent
\begin{CJK*}{UTF8}{bsmi} % bkai : this is 楷体
這是一個傳統的中國文字
\end{CJK*}
 
\end{document}

xeCJK solution

% !TEX encoding = UTF-8
% !TEX program = xelatex

% package xeCJK utilise xelatex to compile

\documentclass{article}
 
\usepackage{xeCJK}
 
\setCJKmainfont{simsun.ttf}
\setCJKsansfont{simhei.ttf}
\setCJKmonofont{simfang.ttf}
 
\begin{document}
 
\section{前言}
在该第一部分中的一些额外的元素可以被添加。巴贝尔包将采取的翻译服务.
 
\section{关于数学部分}
在本节中的一些数学会使用数学模型含中文字符显示。
 
\vspace{0.5cm}
 
這是一個傳統的中國文字
\end{document}

Latex input French Alphabet like "é"

A ISO-8859-1 encoding solution

Env : Win10 bash texmaker and x11
After setting the environment variable DISPLAY, invoke texmaker we get a GUI. However, typing French using Canadian Multilanguage input method (which is in principle in windows OS) won't do in this GUI.
More importantly, Incoding by UTF-8 will not give the right "é" decoded, instead it gives "é". Whereas incode by ISO-8859-1 and all special characters are then well decoded.
Even if we can convert a ISO-8859-1 file to UTF-8 using texmaker. Anyway, converting only the tex file format is tested and it won't work.
So what am I applying ? Use ISO-8859-1 and type using Canadian Multilanguage of windows by using a "pure" windows editor like "Sublime Text 2". Compile using texmaker in win10 Bash.

Two UTF-8 encoding solutions

1.法文断词

using always the UTF-8 encoding. Typing \'e will give é, which is tiring.

2.Package inputenc

\usepackage[utf8]{inputenc}

% !TEX encoding = UTF-8
% !TEX program = pdflatex
\documentclass{article}
\usepackage{CJKutf8}
\usepackage[utf8]{inputenc} % optional
\usepackage[T1]{fontenc}

\begin{document}
% We always use CJK package globally to prevent some bugs.
\begin{CJK}{UTF8}{gbsn}

Without \texttt{CJKutf8} package, the result will be wrong.

Café: 咖啡厅

Gödel: 哥德尔

© 版权所有

\clearpage\end{CJK}
\end{document}
Upside

Works with Chinese, French and German

Downside

Well, if we want to add section names in Chinese for example and put it in the table of contents, this will cause trouble. But if we just want to have several words as comments to ease reading, this solution works perfectly.

Note

If using bibtex, the *.bib file must also be encoded in UTF-8

bibtex

bibtex seems to load the *.bib file at the head of *.tex then proceed. But there will be no special character like "&", if there is tex will bring up error.
How to escape then & ? Use \&

subcaption

usage here