1

Hello and thanks for passing by,

I am new to Ubuntu in general and I have some problems with the LaTeX installation.

Some background before all my barging: First, installing and making LaTeX work was a little easy, but when I needed a package that my installation didn't have (IEEEtran, from texlive-publishers, I think), well, I encountered my first big obstacle.

After some hours of searching and stuff, I finally got it working; just slap some .tex file, sudo pdflatex saidFile.tex. and it was just working fine.

Then I encountered my second big obstacle: trying it out from VScode.

So I work from Windows most of the time and VScode, with the Latex Workshop extension, is heaven on earth, I think, and it works just fine, so I just tried to have it working on Unix, and it has been... well, something I don't quite understand or find, that is why I'm here... sorry for all of this.

So the problem is this: When I compile the file with the IEEEtran with sudo, it works just fine; but when I try to compile it from VScode or the console without sudo, it does not work, it tells me that LaTeX can't find the package.

This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./labInform.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-06-18>

! LaTeX Error: File `IEEEtran.cls' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: cls)

So, I try to start VScode with superuser privileges, but It tells me that it is not correct and I can understand why... sort of.

So yeah... I don't know what to do and have no idea where to search, what to search or how to do this.

Sorry for all of this, and thank you.

  • I think it would be better to ask this on page askubuntu ...BTW: Welcome to TeX.SE! – Mensch Jul 12 at 17:47
  • @Mensch Thank you so much! And yes... my follow up may be in the wrong place. :/ – Luis Alejandro Quiroga Gómez Jul 12 at 19:06
6

You don’t go into detail about how you installed TeX on your system, so it’s difficult to diagnose your problem.

However, you should not be running sudo latex. If you need to, your system is not properly configured. Either install the texlive packages you need on your system or do a custom installation. On Ubuntu, this is either texlive-publishers, or just install texlive-full. If you install vanilla TeX Live and use tlmgr, it’s in the tlmgr package IEEEtran. If you use MikTeX, it’s in the package ieeetran.

You should be able to find the file with kpsewhich IEEEtran.cls. If this command runs but cannot find the file, make sure its parent directories are readable and executable by everyone (sudo chmod 755 /usr/local/texlive/2020/texmf-dist/tex/latex/IEEEtran/, or wherever it is.) If the command can find the file but you cannot open it with more, set it world-readable (sudo chmod 644 /usr/local/texlive/2020/texmf-dist/tex/latex/IEEEtran/IEEEtran.cls or wherever it is.) If your shell cannot find the kpsewhich command itself, make sure to add the directory with your TeX binaries to your PATH, and also the documentation to your MANPATH and INFOPATH. I have the following in a file called /etc/profile.d/texlive.sh:

PATH=/usr/local/texlive/2020/bin/x86_64-linux:$PATH
export PATH
INFOPATH=/usr/local/texlive/2020/texmf-dist/doc/info:$INFOPATH
export INFOPATH
MANPATH=/usr/local/texlive/2020/texmf-dist/doc/man:$MANPATH
export MANPATH

If you do a custom installation, I would advise creating a user tex (or perhaps using the bin account) and running the installation and update commands as, for example,

sudo -u tex -g tex $(which tlmgr) update --self --all

You then run all commands except installers from your own account (just latex, no sudo), but when you install, you are only giving the installer permission to write to your TeX installation, not full root access.

Update

Now that the OP has posted an answer, I’d like to follow up on some of the remaining questions they had.

You do not need to install TeX Live as root, although that will work. The reason you might not want to is security: if you install as root, every package install script runs sudo root. You can create a new user and group that owns only the TeX installation with

sudo adduser --system --group --home-dir /usr/local/texlive tex

This will create a new user and group account that cannot log in and owns only the TeX Live directory. You can, however, run commands as sudo -u tex. The sole purpose of this account is to run TeX installers and updates. That way, they only have permission to read and modify your TeX distribution.

Having done this, you want to create a local TeX tree that tex owns, and make sure that only TeX can add and remove files there, but everyone else can use cd and ls on it.

sudo mkdir /usr/local/texlive
sudo chown tex:tex /usr/local/texlive
sudo chmod 755 /usr/local/texlive

(You describe chmod as generating a file. but what it does is set file permissions. I’m using the old-fashioned octal codes because I’m a UNIX grognard. What’s relevant here is that 755 means everyone can read and execute a file, but only you can write it.)

If you already have this directory, you can remove it and start over, or just hand ownership to tex with

chown -R tex:tex /usr/local/share/texlive/

You can now install TeX Live, as tex, to this new directory that TeX owns. From the directory where you unpacked the TeX Live installer:

chmod 755 install-tl
sudo -u tex -E ./install-tl

The option -u tex means run as the user tex, and -E means preserve the environment variables, for example LANG to determine the language. By default, the installer should put the files in the new directory you just created, /usr/local/texlive/. Since tex owns this directory, it can.

There’s still some set-up left to do. First, you need to add your TeX Live directories to your PATH, MANPATH and INFOPATH environment variables, ahead of the system directories. Reposting from above: you can save the following to a file named /etc/profile.d/texlive.sh and it will load the next time you open a shell.

PATH=/usr/local/texlive/2020/bin/x86_64-linux:$PATH
export PATH
INFOPATH=/usr/local/texlive/2020/texmf-dist/doc/info:$INFOPATH
export INFOPATH
MANPATH=/usr/local/texlive/2020/texmf-dist/doc/man:$MANPATH
export MANPATH

If you exec bash -login to reload your environment, latex --version should give you pdfTeX 3.14159265-2.6-1.40.21 (TeX Live 2020). You should also be able to run man latex and info latex.

The command to update your tex installation is long and annoying, but you can create an easy-to-remember alias. Edit the file ~/.profile and add the following line at the end:

alias update-tex=`sudo -u tex -E $(which tlmgr) update --self --all`

The next time you open a command prompt (or refresh it with exec bash -login), you can update by typing update-tex.

Installing Non-Libre Fonts from CTAN

There’s a bit of a gotcha if you want to install getnonfreefonts from CTAN. You might be tempted to install to your user directory, because that’s the only way that works out of the box. You want to install as --sys, not --user. Installing 8-bit fonts as a user is a trap. This requires a little trick, but it works. If you install as user, the installer will run updmap as a user, which will create a font map in your user directory. That will appear to work at first, but it will hide the system map from you and not be updated when you update the system map, so your map file will get more and more out of date.

The command you have to run for the installer to work is

sudo -u tex -E --preserve-env=PATH $(which texlua) install-getnonfreefonts

This command creates a perl script to install the fonts, which you run with

sudo -u tex -E --preserve-env=PATH /usr/local/texlive/2020/texmf-dist/scripts/getnonfreefonts/getnonfreefonts.pl --sys --all --refreshmap --http

Installing Other Local Files

Sometimes, you might want to download TeX files that are not available as TeX Live packages, such as your publisher’s class file or the Type 1 fonts for Georgian. You usually want to put these in a subdirectory of TEXMFLOCAL (/usr/local/texlive/texmf-local/) . rather than TEXMFHOME (~/texmf/) . You can copy a directory with sudo -u tex cp -r. After manually installing new files, run

sudo -u tex -E $(which texhash)
sudo -u tex -E $(which updmap-sys)

This makes sure your indices and map files are up to date.

If you only need them for one project, you can copy them to your project directory.

Installing and Using Fonts

You can install new fonts for your user account by saving them to ~/.fonts/, or for everyone by saving them to /usr/local/share/fonts/.

You might want to add your TeX tree to the system font paths. (Or even need to, for XeTeX to consistently find them.) The file to do this is texlive-fontconfig.conf, and you can enable it by creating a symbolic link to it in the directory /etc/fonts/conf.d/:

sudo ln -s /usr/local/texlive/2020/texmf-var/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive2020.conf

I additionally created a file with the same format to index the fonts in my TEXMFLOCAL tree. I saved the following as /etc/fonts/conf.d/09-texmf-local.conf:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <dir>/usr/local/texlive/texmf-local/fonts/opentype</dir>
  <dir>/usr/local/texlive/texmf-local/fonts/type1</dir>
  <dir>/usr/local/texlive/texmf-local/fonts/truetype</dir>    
</fontconfig>

I gave these files a low number, such as 09, so that they will be searched before the system directories. The fonts in my TeX directories are usually more up-to-date..

Both XeTeX and LuaTeX should automatically refresh their databases the next time you request a font it doesn’t know about, but you can manually make them do it with

sudo fc-cache -fsv
luaotfload-tool --update --local --prefer-texmf

Other Optional Stuff

Some people recommend making a dummy apt package to prevent a second version of texlive from being automatically installed. I personally have not had that problem.

| improve this answer | |
  • Thank you so much for your answer! I had a lot of problems with the installation, first I tried to install LaTeX from here, using only the sudo apt install texlive-latex-recommended but It didn't work quite well, so, I tried to uninstall it, with sudo apt remove texlive, and install it again with the steps of the official page and using the installation script. After all of that I installed the sudo apt install texlive-publishers, and thats... all I did. – Luis Alejandro Quiroga Gómez Jul 12 at 14:24
  • 1
    @LuisAlejandroQuirogaGómez Glad it works, although if you installed from tl-install, you should not also need to install any apt packages for texlive. You’d get two separate installations, of which you’re only supposed to use the vanilla one. – Davislor Jul 12 at 17:39
  • You are right, I just found out that. It was quite a journey and I got it working. Thank you so much! – Luis Alejandro Quiroga Gómez Jul 12 at 19:07
1

Well, I come with a big answer, for anybody having more or less the same problem. Many, many thanks to @Davislor for the previous answer and for the help. I am using Ubuntu 20.04.

I'll try to divide the problem because all the things that helped me where on different sites and for different problems, I'll try to give all the references and the credit for the pages and users.

I think this does not belong to the original question or it does... I don't know, maybe this is sort of an installation guide... but here I go.

I started with clearing and uninstalling the LaTeX that I had, so this is from the beginning...


Installing LaTeX

For the install, I just followed most of the official installation, but it does not articulate much about it for Linux (in this case Ubuntu); I downloaded the tl-unx.tar.gz from the official site, here, unzip that, and generate the Perl script with the chmod, as:

chmod +x install-tl

Then, I launched the script as a superuser, although in the official page says something like this:

official installation

I thought this could be a problem, but otherwise, the script can't install LaTeX, as the page suggests and I don't quite know how to do it another way. Some other important thing that I did... I don't know if it is a good thing or something, is that I followed the comment from @Andrew Stacey about the umask, you can see the comment here.

Then, I just followed the script instructions, but I selected the packages that make my LaTeX installation weight about ~1.6GB, so it is a 'custom-ish' installation.

So here... I think LaTeX is fully installed if you use another configuration or something. Is up to you.

Something very, very important is to set the PATH variable correctly for LaTeX, on the official installation guide they tell you how to do it. This will come in handy later if you want to install packages independently.


Installing individual packages

After the installation, I thought everything was ok and I tried to compile the file, without superuser permission, that I wanted (the one with the \documentclass[conference]{IEEEtran}), and as @Davislor said, everything worked! Or most of it, the problem now was different, it showed me another problem, that I had struggled for some time; it didn't find the float.sty package.

This I don't understand that much, but when I installed LaTeX following this instructions, everything seemed to be working fine but I found a big problem: this problem. I thought that updating the PATH variable would work, but it didn't.

I was a little afraid that I've encountered the same problem with the float.sty package but I still tried and it worked out with the tlmgr utility. But yet, another problem; the permission problem when installing package from tlmgr.

Following the instruction on that post and this one, helped me solve all of my problems. So now I can install any package as:

sudo env PATH="$PATH" tlmgr install <name of package>

And VScode is working just fine.


Finally, I'm so sorry for all of my barging and thanks to @Davislor who encouraged me to jump into this rabbit hole. And I hope that this helps anyone who encounters the same issues as me.

| improve this answer | |
  • 1
    I updated my answer with detailed instructions to install the same way I did. Now that I’ve written them, I might want to post it as an answer to the related canonical question. – Davislor Jul 13 at 5:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.