A Light-weight TeX Live Docker Image for LaTeX
texlive-small is a TeX Live Docker image with scheme-small installation and some common packages.
It allows you to write LaTeX and generate high quality pdf
files.
Also, it focuses on English and traditional Chinese, so its size is much less than the TeX Live with scheme-full installation.
- Step 1. Install
docker
by following Docker official installation guide. Docker is cross-platform so you can run texlive-small on Mac OSX / Linux / Windows. - Step 2. To download the image, run
docker pull weichuntsai/texlive-small:1.1.0
- Step 3. To initialize the container, run
docker run --name ${The Container Name You Want} -dt -v ${Your Directory for Tex files}:/home weichuntsai/texlive-small:1.1.0
For example,
docker run --name mylatex -dt -v /Users/jimmy_tsai/Documents:/home weichuntsai/texlive-small:1.1.0
- Step 4. To enter into the container you initialized in Step 3 (assume its name is
mylatex
), run
docker exec -it mylatex bash
For what commands you can use in this container, please refer to the following Usage parts.
To see README
in the container, just run:
$ more /README-texlive-small.md
The command is as below:
$ txrun ${tex_file} ${engine_type}
where tex_file
is your tex
, and engine_type
is the LaTeX engine and it could be one of xelatex
, latex
, or pdflatex
.
Now we are going to explain which engine_type
you should use.
Let's assume your tex
is my_input.tex
, then:
- Scenario 1 - if the
tex
contains the command\usepackage{fontspec}
(because you want to use\setmainfont{another font}
to change the font), then you have to run:
$ txrun my_input.tex xelatex
- Scenario 2 - if the
tex
contains non-English content (for example, traditional Chinese), then you have to run:
$ txrun my_input.tex xelatex
- Scenario 3 - if the
tex
(without\usepackage{fontspec}
) contains English content andeps
figures, then you can run:
$ txrun my_input.tex xelatex
or
$ txrun my_input.tex latex
- Scenario 4 - if the
tex
(without\usepackage{fontspec}
) contains English content and does not containeps
figures, then you can run:
$ txrun my_input.tex xelatex
or
$ txrun my_input.tex latex
or
$ txrun my_input.tex pdflatex
Note that txrun
is just a convenient wrapper of (xe/pdf)latex and would remove some derived files you don't need:
- What
txrun my_input.tex xelatex
does is
rm my_input.aux my_input.bbl my_input.blg my_input.idx my_input.ilg my_input.ind my_input.lof my_input.log my_input.lot my_input.out my_input.toc my_input.dvi
xelatex my_input.tex
bibtex my_input.aux
xelatex my_input.tex
xelatex my_input.tex
rm my_input.aux my_input.bbl my_input.blg my_input.idx my_input.ilg my_input.ind my_input.lof my_input.log my_input.lot my_input.out my_input.toc my_input.dvi
- What
txrun my_input.tex latex
does is
rm my_input.aux my_input.bbl my_input.blg my_input.idx my_input.ilg my_input.ind my_input.lof my_input.log my_input.lot my_input.out my_input.toc my_input.dvi
latex my_input.tex
bibtex my_input.aux
latex my_input.tex
latex my_input.tex
dvipdf my_input.dvi
rm my_input.aux my_input.bbl my_input.blg my_input.idx my_input.ilg my_input.ind my_input.lof my_input.log my_input.lot my_input.out my_input.toc my_input.dvi
- What
txrun my_input.tex pdflatex
does is
rm my_input.aux my_input.bbl my_input.blg my_input.idx my_input.ilg my_input.ind my_input.lof my_input.log my_input.lot my_input.out my_input.toc my_input.dvi
pdflatex my_input.tex
bibtex my_input.aux
pdflatex my_input.tex
pdflatex my_input.tex
rm my_input.aux my_input.bbl my_input.blg my_input.idx my_input.ilg my_input.ind my_input.lof my_input.log my_input.lot my_input.out my_input.toc my_input.dvi
There are 2 ways to install fonts you like:
apt-get install ${font_package_name}
to install the fonts in Ubuntu library.- Download the font and run
addfont
. For example, you can visit https://fonts.google.com/specimen/Roboto and click "Download family" button to download "Roboto" font. The downloaded file is azip
file. Unzip it and you would get an unzipped folder called "Roboto". Then in thetexlive-small
container, go to the directory containing "Roboto" folder and then runaddfont ./Roboto
.
Just run fc-list
Just run fc-list : family
Roboto
-> sans-serif for EnglishNoto Serif TC
-> serif for traditional ChineseNoto Sans TC
-> sans-serif for traditional Chinese
Latex
has its default English font. If you wan to change it (ex: you want to change it into Roboto
), please do the following:
In your tex
, before the line \begin{document}
, add lines as below
% In your tex file
\usepackage{fontspec}
\setmainfont{Roboto} % Fill in any English font name you installed.
\begin{document}
...
\end{document}
There are 2 scenarios
In your tex
, before the line \begin{document}
, add lines as below
% In your tex file
\usepackage{xeCJK}
\setCJKmainfont{Noto Serif TC} % Fill in any CJK font name you installed.
\begin{document}
...
\end{document}
In your tex
, before the line \begin{document}
, add lines as below
% In your tex file
\usepackage[BoldFont, SlantFont]{xeCJK}
\setCJKmainfont{AR PL UMing TW} % Fill in any CJK font name you installed.
\begin{document}
...
\end{document}
$ tlmgr search --global ${package_name}
For examle, to search the package named marginnote
:
$ tlmgr search --global marginnote
$ tlmgr search --global --file ${file_name}
For example, to search the package which contains the file marginnote.sty
:
$ tlmgr search --global --file marginnote.sty
$ tlmgr install ${package_name}
For example, to install the package marginnote
:
$ tlmgr install marginnote
$ tlmgr remove ${package_name}
For example, to remove the package named marginnote
:
$ tlmgr remove marginnote
$ tlmgr option repository ${repo_link}
For example:
$ tlmgr option repository http://mirror.ctan.org/systems/texlive/tlnet
When you search / install packages and find that tlmgr
is pending for a long time (server error or no reponse),
in this case, you could consider to change the package repository.
$ fc-list
In fact you can just download the tds.zip
of the package you want from CTAN then install it manually.
For example, if you want to install marginnote
:
- Step 1. In your host (not Docker container) environment, open the browser and go to CTAN
- Step 2. Search
marginnote
then enter into themarginnote
page of CTAN - Step 3. Download the TDS archive
marginnote.tds.zip
- Step 4. Copy this
marginnote.tds.zip
into the Docker container. For example: we copy it from/Users/jimmy_tsai/Downloads
into/root
of the container:
docker cp /Users/jimmy_tsai/Downloads/marginnote.tds.zip ${container_id}:/root
- Step 5. In the Docker container, go to
/root
and unzipmarginnote.tds.zip
to$TEXMFHOME
. For example:
$ cd /root
$ unzip marginnote.tds.zip -d $TEXMFHOME
Basiclly no need to update tlmgr
index.
In fact you can just download the tds.zip
of the package you want from CTAN then install it manually.
For example, if you want to install marginnote
:
- Step 1. In your host (not Docker container) environment, open the browser and go to CTAN
- Step 2. Search
marginnote
then enter into themarginnote
page of CTAN - Step 3. Download the TDS archive
marginnote.tds.zip
- Step 4. Copy this
marginnote.tds.zip
into the Docker container. For example: we copy it from/Users/jimmy_tsai/Downloads
into/root
of the container:
docker cp /Users/jimmy_tsai/Downloads/marginnote.tds.zip ${container_id}:/root
- Step 5. In the Docker container, go to
/root
and unzipmarginnote.tds.zip
to/usr/local/texlive/texmf-local/
. For example:
$ cd /root
$ unzip marginnote.tds.zip -d /usr/local/texlive/texmf-local/
- Step 6. Update
tlmgr
index
$ mktexlsr /usr/local/texlive/texmf-local
The key point is that you have to use the cls
(assume it is some_journal.cls
)
of the journal in your tex
by the line \documentclass{some_journal}
.
Journals usually provide a template package (usually it is a zip
)
containing a cls
(which defines the journal style) and some template tex
files.
For different journals, there are usually 2 scenarios for the template package:
- Scenario 1. The package provides a
cls
and a templatetex
. Usually the templatetex
already used thecls
in\documentclass
and what you have to do is to modify the text content of the templatetex
. - Scenario 2. The package provides a
tds.zip
and a templatetex
. First, you have to unziptds.zip
to TeX Live directory, and then you can modify the text content of the templatetex
.
Here we use IEEE for Scenario 1 and Physical Review Journals for Scenario 2 as demonstration examples.
- Step 1. Google the keywords "IEEE latex template", and you probably find some link like this link
- Step 2. Download the template package (assume it is a
zip
) from the page you found in Step 1. - Step 3. Unzip the template package, it contains a
cls
(assume it isIEEEtran.cls
) and a templatetex
. - Step 4. In the template
tex
, it usually already usedIEEEtran.cls
by the line\documentclass[conference]{IEEEtran}
, so what you have to do is to modify the text content of the templatetex
. - Step 5. After edited the template
tex
(assume it isconference_041818.tex
), run
txrun conference_041818.tex latex
- Step 1. Google the keywords "physical review journal latex template", and you probably find some link like this link
- Step 2. Download the template package (assume it is a
zip
) from the page you found in Step 1. - Step 3. Unzip the template package, it contains a
tds.zip
(assume it isrevtex4-1-tds.zip
) and aREADME
. - Step 4. Following the
README
to unzip therevtex4-1-tds.zip
to TeX Live directory and update TeX Live package index. Usually the commands are like this
$ unzip revtex4-1-tds.zip -d /usr/local/texlive/texmf-local/
$ mktexlsr /usr/local/texlive/texmf-local
- Step 5. Find the template
tex
in the unzippedtds.zip
and modify the text content in it. For exmaple, it is usually in/usr/local/texlive/texmf-local/doc/latex/revtex/sample/aps
and/usr/local/texlive/texmf-local/doc/latex/revtex/sample/aip
. - Step 6. After edited the template
tex
(assume it isapssamp.tex
), run
txrun apssamp.tex latex
Finally I list 2 reminds here:
- Remind 1. You can try
xelatex
orpdflatex
for the 2nd argument (LaTeX engine) oftxrun
and see if the result is OK. For different journals, different LaTeX engines could cause a little different visual effetcs. - Remind 2. If you have
eps
figures in yourtex
, please do NOT usepdflatex
for the LaTeX engine.