Coder Social home page Coder Social logo

how-to-use-latex-in-termux's Introduction

How to use LaTeX in Termux with custom fonts

  1. Install TeX Live and dependences
# install texlive
apt install texlive

# install fontconfig-utils which includes `fc-list`
apt install fontconfig-utils

# change the remote repository to the mirror close to you 
tlmgr option repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet

# update tlmgr
tlmgr update --all
  1. Install custom fonts
# make a new directory to store your custom fonts
CUSTOM_FONT_PATH="/data/data/com.termux/files/usr/share/fonts/YOUR_DIR_NAME"
mkdir -p "${CUSTOM_FONT_PATH}"

# copy fonts from somewhere else to the path of your custom fonts
cp [YOUR_FONTS_PATH/*] "${CUSTOM_FONT_PATH}"
chmod 744 "${CUSTOM_FONT_PATH}"/*
fc-cache -f -v

# better to export the path in ~/.bashrc
export OSFONTDIR="/data/data/com.termux/files/usr/share/fonts"

# add the font Fandol
tlmgr install fandol
  1. Install LaTeX packages
# reinstall  l3packages
tlmgr install --reinstall --with-doc --with-src l3packages

# install ctex to parse Chinese if you need
tlmgr install --with-doc --with-src ctex
  1. Write a LaTeX demo in file demo.tex
# goto a temporary directory
cd $(mktemp -d); pwd

DEMO_FILE=$demo.tex$
echo "\document{article}" > "${DEMO_FILE}"

# "font=windows" if you copied Chinese fonts from Windows
echo "\usepackage[fontset=windows]{ctex}" >> "${DEMO_FILE}"

echo "\begin{document}" >> "${DEMO_FILE}"

echo 'Hello $\LaTeX$' >> "${DEMO_FILE}"
echo "测试" >> "${DEMO_FILE}" # or in other languages 

echo "\end{document}" >> "${DEMO_FILE}"
  1. compile the LaTeX file demo.tex
xelatex -synctex=1 -interaction=nonstopmode demo.tex

# install lost packages if needed
tlmgr install --with-doc --with-src LOST_PACKAGE

xelatex -synctex=1 -interaction=nonstopmode demo.tex
tlmgr install --with-doc --with-src LOST_PACKAGE

xelatex -synctex=1 -interaction=nonstopmode demo.tex
tlmgr install --with-doc --with-src LOST_PACKAGE
# ...
  1. Open the PDF file by your Android PDF reader
termux-open demo.pdf

how-to-use-latex-in-termux's People

Contributors

huangyxi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.