2

I am trying to install LaTeX on my Android device (no root). I didn't find an application to compile TeX documents offline. By following instructions from TeXLive — on Android, I installed Termux from Play Store and installed TeXLive using the command;

pkg install texlive

The process was successful. But I don't know if I am able to compile my documents now. Please help me. What should I do to compile TeX documents offline?

(I know that there are many questions on this topic. But they are seriously outdated and the solutions provided don't work for me. That is why I opened this question)

Another link https://wiki.termux.com/wiki/TeX_Live

Andrew T.
  • 107
mig001
  • 231
  • After your installation, did any command like tex is found and return something ? – R. N Jan 02 '20 at 10:07
  • @R. N I don't remember actually. So I just entered the command again. Following is what I seen. upgraded, 0 newly installed, 0 to remove and 15 not upgraded. $ – mig001 Jan 02 '20 at 12:40
  • @Johannes_B Sorry I still don't understand – mig001 Jan 02 '20 at 12:43
  • Why do you want to compile documents on an Android device? – Johannes_B Jan 02 '20 at 12:47
  • @Johannes_B Word processors available on Android are really messy and can't manage mathematical equations. Microsoft word mobile support them but inserting equation each and every time is really painful. Latex seems fit for me. I have pc with texlive full package. But it can't be carried to everywhere – mig001 Jan 02 '20 at 14:57
  • 1
    @ACA, I don't know what the command you entered in your termux does but it seems that your installation is not done well ; because on my computer when I enter the command tex, I get the something like TeX 3.14159265 (TeX Live 2019) kpathsea version 6.3.1 Copyright 2019 D.E. Knuth.. Therefore if you get something else your TeXLive is not well installed or linked to your terminal. – R. N Jan 02 '20 at 15:18
  • @R. N , This is thr output for the command tex in termux. $tex This is TeX, Version 3.14159265 (TeX Live 2019/Termux) (preloaded format=tex) ** – mig001 Jan 02 '20 at 15:41

3 Answers3

3

Finally able to compile tex files on Android

Steps;

  • Install Termux from Google Play Store
  • Give Termux the permission to access your storage from settings
  • Run pkg install texlive-full
  • Run pkg install texlive-tlmgr
  • Create .tex file using editor like VerbTex (Download it from Play Store) if you don't have .tex file in your storage
  • Run pdflatex
  • After double asterisks input your storage location
  • Once the pdf is created you can open it by termux-open file.tex --view

Some interesting threads;

https://tex.stackexchange.com/a/522898/193507

https://tex.stackexchange.com/a/522823/193507

mig001
  • 231
  • 1
    I am a bit disturbed by the fact that (according to what I understand) you can not go to the directory of your abc.tex and compile there. So I wonder where is the abc.pdf produced and where are the TexLive installation ? perhaps you are missing one environment variable. Thus if you compile in your home folder where the TeXlive folder is also present everything is fine but if you compile somewhere else you get the previous error we discussed with files not found. – R. N Jan 04 '20 at 14:20
  • @R. N I used VerbTex to create a local .tex file. Then searched in files to find out where it is stored. From my experience I understand that where you store your tex file doesn't matter. You should know the correct path to reach the file. I don't know where my pdf files are stored. But after I could open them using above commands it was there in internal storage>Download. I don't know how or why. But it worked! That is what all I know. – mig001 Jan 04 '20 at 14:28
  • 1
    If it is good for you it is good for me. It was just to avoid you some side effects. Enjoy LateX on your Android ! – R. N Jan 04 '20 at 14:32
1

If you have file named test.tex which contains :

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\begin{document}
toto
\end{document}

Then to compile it offline from your termux on android enter the following command in the folder (directory) containing your file:

pdflatex ./test.tex

Finally go into your directory (some new files should be present as the results of the compilation) and click on the PDF file to open it with your favourite PDF reader

R. N
  • 1,076
  • Thanks for the answer. I created local tex file document.tex using VerbTex. Moved the file to internal storage/downloads. The command didn't work for me. I don't understand the line " enter the following command in the folder..." What is meant by folder? – mig001 Jan 02 '20 at 16:24
  • Please don't miss a single step from opening termux to opening document.pdf I have a very little knowledge about it. Please – mig001 Jan 02 '20 at 16:30
  • @ACA folder or directory if you prefer: that means the command ls should return . .. ./test.tex. Then go into your directory (storage/downloads if you put the file there) and click on the PDF file to open it with your favourite PDF reader.

    Otherwise what do you mean by the command didn't work for me ? What was the prompt output ?

    – R. N Jan 02 '20 at 17:14
  • Is pdflatex on the PATH or whatever it's called there? Basically, what happens, if you call it? You should see something like This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdflatex) restricted \write18 enabled. ** and you'd be able to get out with Ctrl-D. – Oleg Lobachev Jan 02 '20 at 17:50
  • @R. N I am sharing terminal transcript for you http://simp.ly/publish/K7fpT6 – mig001 Jan 02 '20 at 17:53
  • This is final result. ~I can't find the format file `pdflatex.fmt'! – mig001 Jan 02 '20 at 17:56
  • @ACA it seems more that the first issue is that the file dehypht-x-2019-04-04.tex is not found. My guess is that the installation is not complete or something of this kind. – R. N Jan 02 '20 at 20:28
  • @R. N Ok. I will check the installation. – mig001 Jan 03 '20 at 13:54
  • @R. N , I removed my previous installations and installed texlive-full package so that no package is missed. Still my issue is not solved. Terminal transcript: http://simp.ly/publish/46BnN9 – mig001 Jan 03 '20 at 17:02
  • @R. N Finally I got a positive feed back. I am sharing terminal transcript with you. http://simp.ly/publish/5J4HRF I don't know how to open abc.pdf or where is it stored. Please help. I won't disturb you anymore – mig001 Jan 03 '20 at 17:39
  • @R. N Finally it worked!!!!! Thanks a lot. https://tex.stackexchange.com/a/522823/193507 – mig001 Jan 03 '20 at 18:25
  • @ACA Verry good! Can you tell us what was the key points go to from failing to completing compilation ? because your termux transcriptions do not explain how and why it is working. – R. N Jan 04 '20 at 09:44
  • @R. N With pleasure. With all the things I learnt from here, I created a YouTube video.Part 1 https://youtu.be/kGz1MGwwcE0 .Part 2 https://youtu.be/tMb_XcinN8U – mig001 Jan 04 '20 at 10:32
1

I use TeXlive on Termux, as described above. No root needed. Things to know:

  1. For some time, the Termux project has recommended that Termux be side-loaded via F-Droid, rather than directly via Google Play Store. I switched from Google Play to F-Droid, just for Termux, a year or two ago. No problem. The reason offered by Termux is that Google Play might tighten the ability for an app (termux) to download other things (its software).

  2. Within Termux, you are always "root" there, and do not need (and cannot get) sudo permission to install or modify things. This is because you are jailed within the Termux app. You can read and write non-executable files to common storage, but you cannot modify anything exterior to Termux (unless your Android device is rooted).

  3. Currently, Termux has packages texlive-bin and texlive-installer. The first is only the binaries, built for the jailed Termux path. The installer is the same as provided by TUG, except that you will not install any of its binaries. Unless your device has a lot of on-board storage (not removable card), only install as much as you need. You can add more later.

  4. Because the binaries must be built specifically for Termux, they arrive much later than the TUG release. At the time I write this, the binaries are still 2022, but TUG is at 2023, so that the package installer fails (wrong year). TUG and CTAN have gotten much criticism for this practice.

  5. In Termux, the TeX packages are installed in a directory that differs from the TeX default. Once in a while, a TeX script update will revert paths to the TeX defaults, and then TeX cannot find its packages via kpathsea. It is possible to patch the scripts. However, a simpler solution is to create a .bashrc file in your home directory. It is automatically read at Termux launch. In this file, define the various TeX internal environment variables. Here is how mine looks:

export TEXMFROOT="$PREFIX/share/texlive"
export TEXMFOS="$TEXMFROOT"
export TEXMFDIST="$TEXMFROOT/texmf-dist"
export TEXMFLOCAL="$TEXMFROOTtexmf-local"
export TEXMFVAR="$HOME/.local/texlive2022/texmf-var"
export TEXMFCONFIG="$HOME/.local/texlive2022/texmf-config"
export TEXMFHOME="$HOME/.local/texmf"

Your paths may differ.

rallg
  • 2,379