TexLive: Difference between revisions

From NixOS Wiki
imported>Caaaaaa
texlive.combine
Add a section on adding a custom package to the combined package set
 
(9 intermediate revisions by 4 users not shown)
Line 4: Line 4:


== Installation ==
== Installation ==
Since TeX Live consist of thousands of packages, to make managing it easier, NixOS provides the following sets:
Since TeX Live consist of thousands of packages, to make managing it easier, NixOS replicates the  
organization of TeX Live into 'schemes' and 'collections'


* full, <code>nixpkgs.texlive.combined.scheme-full</code>, contains every TeX Live package.
The following Tex Live schemes are available:


* medium, <code>nixpkgs.texlive.combined.scheme-medium</code>, contains everything in the small scheme + more packages and languages.
{| class="wikitable"
 
|-
* small, <code>nixpkgs.texlive.combined.scheme-small</code>, contains everything in the basic scheme + xetex, metapost, a few languages.
! Name of TeX Live package
 
! Name of Nixos-derivation
* basic, <code>nixpkgs.texlive.combined.scheme-basic</code>, contains everything in the plain scheme but includes latex.
! Comment
 
|-
* minimal, <code>nixpkgs.texlive.combined.scheme-minimal</code>, contains plain only.
|width=20% valign=top| Scheme-full
 
|width=50% valign=top| <code>nixpkgs.texlive.combined.scheme-full</code>
* teTeX, <code>nixpkgs.texlive.combined.scheme-tetex </code>, contains more than the medium scheme, but nowhere near the full scheme
|width=30% valign=top| Contains every TeX Live package
 
|-
* ConTeXt, <code>nixpkgs.texlive.combined.scheme-context</code>.
| Scheme-medium
 
| <code>nixpkgs.texlive.combined.scheme-medium</code>
* GUST, <code>nixpkgs.texlive.combined.scheme-gust </code>.
| contains everything in the small scheme + more packages and languages
|-
| Scheme-small
| <code>nixpkgs.texlive.combined.scheme-small</code>
| contains everything in the basic scheme + xetex, metapost, a few languages.
|-
| Scheme-basic
| <code>nixpkgs.texlive.combined.scheme-basic</code>
| contains everything in the plain scheme but includes latex.
|-
| Scheme-minimal
| <code>nixpkgs.texlive.combined.scheme-minimal</code>
| contains plain only.
|-
| Scheme-teTeX
| <code>nixpkgs.texlive.combined.scheme-tetex</code>
| contains more than the medium scheme, but nowhere near the full scheme.
|-
| Scheme-ConTeXt
| <code>nixpkgs.texlive.combined.scheme-context</code>
| contains ConTeXt
|-
| Scheme-GUST
| <code>nixpkgs.texlive.combined.scheme-gust</code>
| contains gust
|}


===Combine Sets===
===Combine Sets===
Line 29: Line 55:
})
})
</code>
</code>
For a minimal set of packages needed for Emacs Orgmode, as described in org-latex-default-packages-alist variable, install these packages:
<pre>
{ config, pkgs, ... }:
let
  tex = (pkgs.texlive.combine {
    inherit (pkgs.texlive) scheme-basic
      dvisvgm dvipng # for preview and export as html
      wrapfig amsmath ulem hyperref capt-of;
      #(setq org-latex-compiler "lualatex")
      #(setq org-preview-latex-default-process 'dvisvgm)
  });
in
{ # home-manager
  home.packages = with pkgs; [
    tex
  ];
}
</pre>
== Adding a Custom Package ==
If you have a custom LaTeX package or style file that is not part of the TeXLive distribution, you can add it to the package set like this:
First, create a derivation for your package. The contents of <code>$out/tex</code> will later be placed in <code>texmf/tex</code>
latex-corporate-identity = pkgs.stdenvNoCC.mkDerivation {
  name = "latex-corporate-identity";
  src = ./path/to/package/tree;
  installPhase = "cp -r $src $out";
  passthru.tlType = "run";
};
texlive-corporate-identity = {
  pkgs = [ latex-corporate-identity ];
};
The directory tree under the path specified as src looks like this:
└── tex
    └── latex
        └── corporate-identity
            ├── corporate-identity.sty
You can now add the package to the combined set as you would with any other texlive package:
tex = pkgs.texlive.combine {
  inherit (pkgs.texlive) scheme-full;
  inherit texlive-corporate-identity;
};


== Troubleshooting ==
== Troubleshooting ==
=== Missing <code>lmodern.sty</code> ===
=== Missing <code>lmodern.sty</code> ===
If LaTex (perhaps through Pandoc) complains about missing <code>lmodern.sty</code>, make sure you have at least <code>texlive.combined.scheme-medium</code> installed (-full should work as well; while -small worked for some, but not for all).
If LaTex (perhaps through Pandoc) complains about missing <code>lmodern.sty</code>, make sure you have at least <code>texlive.combined.scheme-medium</code> installed (-full should work as well; while -small worked for some, but not for all).
=== Invalid fontname ‘Latin Modern Roman/ICU’ ===
If you get an error message saying “Invalid fontname ‘Latin Modern Roman/ICU’. . . ”, then you need to add the
entry '''lmodern''' into your configuration in the section '''fonts.fonts''' and rebuild. 


== Further reading ==
== Further reading ==
* [https://www.tug.org/texlive/doc/texlive-en/texlive-en.html The Tex Live Guide 2018]
* [https://www.tug.org/texlive/doc/texlive-en/texlive-en.html The Tex Live Guide 2018]
* [[Tex]] in NixOS-Wiki
* [https://flyx.org/nix-flakes-latex/ Building LaTeX Documents Reproducibly with Nix Flakes]
[[Category:Applications]]

Latest revision as of 08:22, 4 September 2024

According to Wikipedia:

TeX Live is a free software distribution for the TeX typesetting system that includes major TeX-related programs, macro packages, and fonts.

Installation

Since TeX Live consist of thousands of packages, to make managing it easier, NixOS replicates the organization of TeX Live into 'schemes' and 'collections'

The following Tex Live schemes are available:

Name of TeX Live package Name of Nixos-derivation Comment
Scheme-full nixpkgs.texlive.combined.scheme-full Contains every TeX Live package
Scheme-medium nixpkgs.texlive.combined.scheme-medium contains everything in the small scheme + more packages and languages
Scheme-small nixpkgs.texlive.combined.scheme-small contains everything in the basic scheme + xetex, metapost, a few languages.
Scheme-basic nixpkgs.texlive.combined.scheme-basic contains everything in the plain scheme but includes latex.
Scheme-minimal nixpkgs.texlive.combined.scheme-minimal contains plain only.
Scheme-teTeX nixpkgs.texlive.combined.scheme-tetex contains more than the medium scheme, but nowhere near the full scheme.
Scheme-ConTeXt nixpkgs.texlive.combined.scheme-context contains ConTeXt
Scheme-GUST nixpkgs.texlive.combined.scheme-gust contains gust

Combine Sets

You can install a set with extra packages by using something like

(texlive.combine { inherit (texlive) scheme-medium xifthen ifmtarg framed paralist titlesec; })

For a minimal set of packages needed for Emacs Orgmode, as described in org-latex-default-packages-alist variable, install these packages:

{ config, pkgs, ... }:
let
  tex = (pkgs.texlive.combine {
    inherit (pkgs.texlive) scheme-basic
      dvisvgm dvipng # for preview and export as html
      wrapfig amsmath ulem hyperref capt-of;
      #(setq org-latex-compiler "lualatex")
      #(setq org-preview-latex-default-process 'dvisvgm)
  });
in
{ # home-manager
  home.packages = with pkgs; [
    tex
  ];
}

Adding a Custom Package

If you have a custom LaTeX package or style file that is not part of the TeXLive distribution, you can add it to the package set like this:

First, create a derivation for your package. The contents of $out/tex will later be placed in texmf/tex

latex-corporate-identity = pkgs.stdenvNoCC.mkDerivation {
  name = "latex-corporate-identity";
  src = ./path/to/package/tree;
  installPhase = "cp -r $src $out";
  passthru.tlType = "run";
};


texlive-corporate-identity = {
  pkgs = [ latex-corporate-identity ];
};

The directory tree under the path specified as src looks like this:

└── tex
    └── latex
        └── corporate-identity
            ├── corporate-identity.sty

You can now add the package to the combined set as you would with any other texlive package:

tex = pkgs.texlive.combine {
  inherit (pkgs.texlive) scheme-full;
  inherit texlive-corporate-identity;
};

Troubleshooting

Missing lmodern.sty

If LaTex (perhaps through Pandoc) complains about missing lmodern.sty, make sure you have at least texlive.combined.scheme-medium installed (-full should work as well; while -small worked for some, but not for all).

Invalid fontname ‘Latin Modern Roman/ICU’

If you get an error message saying “Invalid fontname ‘Latin Modern Roman/ICU’. . . ”, then you need to add the entry lmodern into your configuration in the section fonts.fonts and rebuild.


Further reading