<commit_before>---
title: Frequently (?) Asked Questions
date: '2017-12-02'
---

TinyTeX is still a relatively new project, so these are only potential FAQs.

1. **Which version of TeX Live is installed?**

    The (very) latest. Using the very latest version of a software package can be risky. You have been warned. On the other hand, however, let's not pretend we haven't run into problems using the "stable" versions of TeX Live.
    
    Latest or stable? Your call. If you are not comfortable with the latest version, you should not consider TinyTeX.

1. **Do you provide prebuilt binaries of TinyTeX?**

    No. Technically it is easy, but I don't really understand the implications of [the TeX Live license](https://www.tug.org/texlive/LICENSE.TL). Specifically, the license says:
    
    > [...] TeX Live has neither a single copyright holder nor a single license covering its entire contents, since it is a collection of many independent packages.  Therefore, you may copy, modify, and/or redistribute software from TeX Live only if you comply with the requirements placed thereon by the owners of the respective packages.

    That sounds complicated to me.

1. **What is the size of TinyTeX?**

    About 150MB on macOS and Ubuntu, and 220MB on Windows (when installed). You may think it is still too big, but please consider that the size of [BasicTeX](https://www.tug.org/mactex/morepackages.html) for macOS is about 215MB (when installed), and a [basic MiKTeX installer](https://miktex.org/download) for Windows is about 750MB (I didn't check how big it is when installed).
    
    If you create a tarball of TinyTeX on macOS or Ubuntu, it will be only 50MB. This can be very helpful if you install such a tarball on the cloud (e.g., for software testing purposes on Travis CI). The download and installation should take only a few seconds.

1. **What does the TinyTeX installation script do exactly? How do you reduce the size of the gigantic TeX Live?**

    The best way to understand TinyTeX is to [read the source](https://github.com/yihui/tinytex/) under the `tools` directory. Basically, TinyTeX automates the TeX Live installation using a profile file named [texlive.profile](https://github.com/yihui/tinytex/blob/master/tools/texlive.profile) (`./install-tl -profile=texlive.profile`), which only specifies the `infraonly` scheme to be installed first. With this scheme, you cannot really compile any LaTeX documents, but it contains the most important utility `tlmgr` (TeX Live Manager). At this point, the total size is about 80MB.
    
    Then I use `tlmgr` to install a few more commonly used packages (defined in [pkgs-custom.txt](https://github.com/yihui/tinytex/blob/master/tools/pkgs-custom.txt)). With these packages, you should be able to compile most R Markdown documents to PDF. The total size becomes about 150MB.
    
    The fact that I only included a small number of LaTeX packages in TinyTeX is one of the two reasons why TinyTeX is relatively small in size. The other reason is that I excluded the source files and documentation of packages. In `texlive.profile`, you can see these two options:

    ```config
    option_doc 0
    option_src 0
    ```

    Why do I exclude source files? Because they are unlikely to be useful to end-users. Would you really read the source code of a LaTeX package? Probably not, unless you are a developer or advanced LaTeX user. In fact, this also explains why I don't provide prebuilt binaries of TinyTeX: some open-source licenses may require that you provide source files when you redistribute the open-source software. TinyTeX does not redistribute TeX Live, but only provides a custom installation script.

    Why do I exclude the documentations? Tell me honestly: how many times have you found a solution via [StackExchange](https://tex.stackexchange.com), and how many times have you tried to read the package documentation? Even with the full documentation installed, you probably don't even know where to find these documentation files on your computer. The documentation files take a lot of disk space, and I believe they are rarely read by an average user, so they are not included. The address bar of your web browser is the most convenient documentation: type and search.

    The other major factor that affects the size of TeX Live is the font packages, which are usually much bigger than other LaTeX packages, but we cannot really do much about it, unless you do not use `pdflatex`, in which case you may further reduce the size of this small TeX Live distribution.

1. **I'm an R package developer. Are the default LaTeX packages included in TinyTeX enough for me to develop an R package?**

    No, you need a few more: **metafont**, **mfware**, **inconsolata**, and **tex**, mainly because `R CMD check` needs to build manuals to PDF. You can install these packages through either the command line:
    
    ```sh
    tlmgr install metafont mfware inconsolata tex
    tlmgr path add
    ```
    
    or via the R function:
    
    ```r
    tinytex::tlmgr_install(c('metafont', 'mfware', 'inconsolata', 'tex'))
    ```
    
    Another important thing to do is add R's texmf tree to TeX Live. This is not easy to explain, but I have provided a function `tinytex::r_texmf()` to do it. Just do it. See the help page `?tinytex::r_texmf` if you are curious about the technical details.
    
    Although it is irrelevant to TinyTeX, you may also need to install [**texinfo**](https://www.gnu.org/software/texinfo/) (not a LaTeX package), since `R CMD check` may also require it. For macOS users, you can install it via Homebrew: `brew install texinfo`.

1. **I'm a Linux system admin. I want to install TinyTeX for all users.**

    Just add an option `--admin` to the installation script:

    ```sh
    wget -qO- \
      "https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" | \
      sh -s - --admin
    ```
    
    During the installation, it will ask your for password, because it will call `sudo tlmgr path add` to add symlinks of TeX Live binaries to `/usr/local/bin` (this is the only place where `sudo` is used; the rest of the script does not require `sudo`). Without this option, binaries are symlinked to `$HOME/bin` instead.
    
    However, you may still feel uncomfortable with a random script on the Internet asking you for your password. If that is your concern, you can add the `--no-path` option:

    ```sh
    wget -qO- \
      "https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" | \
      sh -s - --admin --no-path
    ```

    Then the installation will not run `sudo tlmgr path add` (hence not requiring root privileges), and you can run this explicitly later:
    
    ```sh
    sudo ~/.TinyTeX/bin/*/tlmgr path add
    ```
    
    If you want to move `~/.TinyTeX` to a different location, see FAQ 8, and remember to run `tlmgr path add` with `sudo` after you move the folder.

1. **I'm a Debian/Ubuntu user. How do I prevent TeX Live from being installed when installing other packages that depend on TeX Live? I don't want (or need) both TinyTeX and the official TeX Live packages to be installed at the same time.**

    Yes, `apt-get install` might install certain `texlive` packages. You can download and install [texlive-local.deb](https://travis-bin.yihui.name/texlive-local.deb) to "fool" `apt-get`.
    <commit_msg>add one more FAQ to fully answer @cboettig's question in yihui/tinytex#1<commit_after>---
title: Frequently (?) Asked Questions
date: '2017-12-02'
---

TinyTeX is still a relatively new project, so these are only potential FAQs.

1. **Which version of TeX Live is installed?**

    The (very) latest. Using the very latest version of a software package can be risky. You have been warned. On the other hand, however, let's not pretend we haven't run into problems using the "stable" versions of TeX Live.
    
    Latest or stable? Your call. If you are not comfortable with the latest version, you should not consider TinyTeX.

1. **Do you provide prebuilt binaries of TinyTeX?**

    No. Technically it is easy, but I don't really understand the implications of [the TeX Live license](https://www.tug.org/texlive/LICENSE.TL). Specifically, the license says:
    
    > [...] TeX Live has neither a single copyright holder nor a single license covering its entire contents, since it is a collection of many independent packages.  Therefore, you may copy, modify, and/or redistribute software from TeX Live only if you comply with the requirements placed thereon by the owners of the respective packages.

    That sounds complicated to me.

1. **What is the size of TinyTeX?**

    About 150MB on macOS and Ubuntu, and 220MB on Windows (when installed). You may think it is still too big, but please consider that the size of [BasicTeX](https://www.tug.org/mactex/morepackages.html) for macOS is about 215MB (when installed), and a [basic MiKTeX installer](https://miktex.org/download) for Windows is about 750MB (I didn't check how big it is when installed).
    
    If you create a tarball of TinyTeX on macOS or Ubuntu, it will be only 50MB. This can be very helpful if you install such a tarball on the cloud (e.g., for software testing purposes on Travis CI). The download and installation should take only a few seconds.

1. **What does the TinyTeX installation script do exactly? How do you reduce the size of the gigantic TeX Live?**

    The best way to understand TinyTeX is to [read the source](https://github.com/yihui/tinytex/) under the `tools` directory. Basically, TinyTeX automates the TeX Live installation using a profile file named [texlive.profile](https://github.com/yihui/tinytex/blob/master/tools/texlive.profile) (`./install-tl -profile=texlive.profile`), which only specifies the `infraonly` scheme to be installed first. With this scheme, you cannot really compile any LaTeX documents, but it contains the most important utility `tlmgr` (TeX Live Manager). At this point, the total size is about 80MB.
    
    Then I use `tlmgr` to install a few more commonly used packages (defined in [pkgs-custom.txt](https://github.com/yihui/tinytex/blob/master/tools/pkgs-custom.txt)). With these packages, you should be able to compile most R Markdown documents to PDF. The total size becomes about 150MB.
    
    The fact that I only included a small number of LaTeX packages in TinyTeX is one of the two reasons why TinyTeX is relatively small in size. The other reason is that I excluded the source files and documentation of packages. In `texlive.profile`, you can see these two options:

    ```config
    option_doc 0
    option_src 0
    ```

    Why do I exclude source files? Because they are unlikely to be useful to end-users. Would you really read the source code of a LaTeX package? Probably not, unless you are a developer or advanced LaTeX user. In fact, this also explains why I don't provide prebuilt binaries of TinyTeX: some open-source licenses may require that you provide source files when you redistribute the open-source software. TinyTeX does not redistribute TeX Live, but only provides a custom installation script.

    Why do I exclude the documentations? Tell me honestly: how many times have you found a solution via [StackExchange](https://tex.stackexchange.com), and how many times have you tried to read the package documentation? Even with the full documentation installed, you probably don't even know where to find these documentation files on your computer. The documentation files take a lot of disk space, and I believe they are rarely read by an average user, so they are not included. The address bar of your web browser is the most convenient documentation: type and search.

    The other major factor that affects the size of TeX Live is the font packages, which are usually much bigger than other LaTeX packages, but we cannot really do much about it, unless you do not use `pdflatex`, in which case you may further reduce the size of this small TeX Live distribution.

1. **I'm an R package developer. Are the default LaTeX packages included in TinyTeX enough for me to develop an R package?**

    No, you need a few more: **metafont**, **mfware**, **inconsolata**, and **tex**, mainly because `R CMD check` needs to build manuals to PDF. You can install these packages through either the command line:
    
    ```sh
    tlmgr install metafont mfware inconsolata tex
    tlmgr path add
    ```
    
    or via the R function:
    
    ```r
    tinytex::tlmgr_install(c('metafont', 'mfware', 'inconsolata', 'tex'))
    ```
    
    Another important thing to do is add R's texmf tree to TeX Live. This is not easy to explain, but I have provided a function `tinytex::r_texmf()` to do it. Just do it. See the help page `?tinytex::r_texmf` if you are curious about the technical details.
    
    Although it is irrelevant to TinyTeX, you may also need to install [**texinfo**](https://www.gnu.org/software/texinfo/) (not a LaTeX package), since `R CMD check` may also require it. For macOS users, you can install it via Homebrew: `brew install texinfo`.

1. **I'm a Linux system admin. How can I install TinyTeX for all users of a system?**

    First, add two options `--admin --no-path` to the installation script:

    ```sh
    wget -qO- \
      "https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" | \
      sh -s - --admin --no-path
    ```
    
    This will install TinyTeX to `~/.TinyTeX`, and this step does _not_ require root privileges. Then you need to add symlinks to `/usr/local/bin` via `sudo`, so that all users of this system can use the TeX Live executables (e.g., `pdflatex`):
    
    ```sh
    sudo ~/.TinyTeX/bin/*/tlmgr path add
    ```

    If you want to move `~/.TinyTeX` to a different location, see FAQ 9, and remember to run `tlmgr path add` with `sudo` after you move the folder, to move sure symlinks under `/usr/local/bin` point to the the new paths correctly.

1. **I'm a Linux admin. I used the above approach to install TinyTeX and added symlinks to `/usr/local/bin`. How can my users without root privileges install LaTeX packages by themselves?**

    Users without root privileges won't be able to install packages via a normal `tlmgr install` command. However, TeX Live has provided a [user mode](https://www.tug.org/texlive/doc/tlmgr.html#USER-MODE) to allow users without root privileges to manage a user-level texmf tree, e.g., a user can install packages to his/her home directory instead of a system directory. With TinyTeX, the user-level texmf tree is at `$HOME/.TinyTeX/texmf-home` (in TeX Live's terms, this is the `TEXMFHOME` variable).
    
    The first thing users have to do is to initialize the tree (create the `TEXMFHOME` directory if it does not exist). It only needs to be done once:
    
    ```sh
    tlmgr init-usertree
    ```
    
    Then when they install packages, they must always use the option `--usermode`, e.g.,
    
    ```sh
    tlmgr --usermode install koma-script xcolor
    ```
    
    For R users, the above commands are equivalent to:
    
    ```r
    tinytex::tlmgr('init-usertree')  # again, only do this once
    tinytex::tlmgr_install(c('koma-script', 'xcolor'), usermode = TRUE)
    ```
    
    However, the user mode of TeX Live can actually be quite complicated, and unfortunately it is not something that I can help with. A few known caveats:
    
    - The worst thing is that users cannot install all packages. For TeX Live, some packages are _relocatable_, and some are not. For example, packages containing executables are not relocatable (e.g., the **metafont** package contains the executable `mf`). If users have to use these packages, only the system admin can help. The good news is that the number of such packages is relatively small, so a conservative strategy is to just pre-install all of them.
    
    - Some packages may require running [`updmap`](https://www.tug.org/texlive/doc/updmap.html) after installation (e.g., font packages for `pdflatex`). Good news is that users should be able to run `updmap-user`, and bad news is that whenever the system admin runs `updmap-sys`, users may have to run `updmap-user` again (if I understand the documentation correctly). For users, the conservative stragety is to run `updmap-user` again when they run into font problems that didn't exist previously (R users can run `system2('updmap-user')`).

1. **I'm a Debian/Ubuntu user. How do I prevent TeX Live from being installed when installing other packages that depend on TeX Live? I don't want (or need) both TinyTeX and the official TeX Live packages to be installed at the same time.**

    Yes, `apt-get install` might install certain `texlive` packages. You can download and install [texlive-local.deb](https://travis-bin.yihui.name/texlive-local.deb) to "fool" `apt-get`.
    
{'fraction_non_alphanumeric': 0.07619217293188432, 'fraction_numerical': 0.004572718094898747, 'mean_word_length': 3.6519337016574585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 23, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '317071', 'n_tokens_mistral': 4732, 'n_tokens_neox': 4447, 'n_words': 2451}