0

Whenever I find something new in XeLaTeX, I always add new packages in the preamble. As a result, it has become very heavy and slow. Are there any packages in my preamble that are unnecessary, because they covered by others? (In order to delete them right now without losing something)

\documentclass[a4paper,10pt]{article}
\usepackage{xltxtra}
\usepackage{xgreek}
\usepackage{mathtools}
\usepackage{amscd}
\usepackage{amsthm}
\usepackage[mathup=sym]{unicode-math}
\usepackage{tikz}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{pgf,tikz}
\usepackage{tkz-tab}
\usetikzlibrary{shapes,arrows,backgrounds}
\usetikzlibrary{scopes,svg.path,shapes.geometric,shadows}
\usepackage[left=1.5cm,right=1.5cm,top=2cm,bottom=1.5cm]{geometry}
\usepackage{kmath,kerkis}
\usepackage{xcolor, colortbl}
\usepackage{fancyhdr}
\usepackage{tcolorbox}
\usepackage{cancel}
\usepackage{shadowtext}
\usepackage{hyperref}
\hypersetup{%
    pdfborder = {0 0 0}
}
\usepackage{multicol}
\setmainfont[Mapping=tex-text]{Kerkis}
\setmathfont[Scale=MatchUppercase]{STIX Two Math}
\tcbuselibrary{listings,theorems,skins,raster,xparse,breakable}
\begin{document}

\end{document}

gildux
  • 487
GSpyros
  • 155

2 Answers2

6

Whenever I find something new in XeLaTeX, I always add new packages in the preamble.

That's a bad policy although your preamble is nothing like as bad as some we see here with literally hundreds of unused packages.

Start from an empty preamble and just add packages as needed.


\usepackage{xltxtra}

Best to avoid that with current xelatex, you could replace by fontspec except here you are already using unicode-math which loads fontspec so simply delete.


\usepackage{xgreek}

OK, assuming you are using Greek (you have not said)


\usepackage{amscd}
\usepackage{amsthm}
\usepackage[mathup=sym]{unicode-math}

All OK, assuming you do have mathematics and commutative diagrams, although as you use tikz you could consider using tikz-cd rather than amscd


\usepackage{tikz}

OK so long as you are using tikz. Loading it loads dozens of files and would be the main cause of your preamble being slow so don't load it if you do not have any tikzpicture.


\usepackage{makeidx}
\usepackage{graphicx}

OK, assuming you have an alphabetic index, and images.


\usepackage{pgf,tikz}

Delete this, tikz load pgf and you already loaded tikz literally two lines earlier


\usepackage{tkz-tab}

An extension of tikz, again load it if you are using it, don't if you are not


\usetikzlibrary{shapes,arrows,backgrounds}
\usetikzlibrary{scopes,svg.path,shapes.geometric,shadows}

If you are using these tikz libraries, OK


\usepackage[left=1.5cm,right=1.5cm,top=2cm,bottom=1.5cm]{geometry}

OK


 \usepackage{kmath,kerkis}

Delete this, this is setting up legacy 8 bit font encodings, but you are using Unicode.


\usepackage{fancyhdr}
\usepackage{tcolorbox}
\usepackage{cancel}
\usepackage{shadowtext}
\usepackage{hyperref}
\hypersetup{%
    pdfborder = {0 0 0}
}
\usepackage{multicol}

All OK assuming you are using those features. Do not load if you are not using them.


\setmainfont[Mapping=tex-text]{Kerkis}
\setmathfont[Scale=MatchUppercase]{STIX Two Math}

OK although you can delete [Mapping=tex-text] it does nothing as that is the default option.


\tcbuselibrary{listings,theorems,skins,raster,xparse,breakable}

OK if you use those features of tcolorbox.


David Carlisle
  • 757,742
  • 3
    We should think about having a policy about these “please clean up my preamble because I don’t want to do it myself” questions. – Gaussler Feb 02 '23 at 12:04
  • 1
    For that reason, I’m voting to close it. – Gaussler Feb 02 '23 at 12:15
  • 3
    @Gaussler you could read the question that way, but you could read it as asking "how to read a preamble" and like similar "how to read an error message" questions, having a few sample answers isn't a bad thing – David Carlisle Feb 02 '23 at 12:49
4

Unnecessary packages depends on your needs and use, so we can't told you what to remove: I may remove some packages I don't need, but it will reflects my usage and not yours.

I always add new packages in the preamble.

When you add a new package, first add a comment that indicates the main purpose and the specific usage you have for it. For example

\usepackage{graphicx} % images inclusion

Second, keep all those lines commented…

%\usepackage{tikz} % draw/plot figures
%\usepackage{makeidx} % build glossary
%\usepackage{graphicx} % include images

…and uncomment only the ones your document really requires. In those cases I also put in the following comment the commands that make me use it.

gildux
  • 487
  • 2
    I don't like it very much when I get files with lots of comments and commented packages in the preamble. I would suggest to build an extra file which list packages with descriptions and personal notes about their usage and to copy only the \usepackage when needed into real document. – Ulrike Fischer Feb 02 '23 at 12:21
  • Yes, and it's a similar approach …because I think original poster is using a kinda template/starting file where all the comments will be. Of course, once hu start a new copy for a fresh document he may (or should for readability) remove unnecessary comment lines. Completely agree. – gildux Feb 02 '23 at 16:42