diff options
Diffstat (limited to 'Master/texmf-dist/doc/latex/first-packages/first-packages.tex')
-rw-r--r-- | Master/texmf-dist/doc/latex/first-packages/first-packages.tex | 384 |
1 files changed, 384 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/first-packages/first-packages.tex b/Master/texmf-dist/doc/latex/first-packages/first-packages.tex new file mode 100644 index 00000000000..47ce64ab1ac --- /dev/null +++ b/Master/texmf-dist/doc/latex/first-packages/first-packages.tex @@ -0,0 +1,384 @@ +\documentclass[11pt]{article} +% \usepackage[utf8]{inputenc} +\usepackage[urw-garamond]{mathdesign} +\usepackage[T1]{fontenc} + +\usepackage[margin=1.2in]{geometry} +\usepackage{multicol} +\setlength{\columnsep}{2em} + +\usepackage{graphicx} % needed for \XeLaTeX command +\usepackage{listings} +\lstset{basicstyle = \small\ttfamily, + keepspaces=true, + columns=fullflexible, + xleftmargin=10pt} + +% Get ISO dates +\usepackage[style=iso]{datetime2} + +% Color for links +\usepackage{xcolor} +% Color theme from Rodryggo Sylva +% https://color.adobe.com/explore?page=2 +\definecolor{darkblue}{HTML}{023059} +\definecolor{lightblue}{HTML}{023E73} +% \definecolor{papyrus}{HTML}{D9D8D7} +\definecolor{papyrus}{HTML}{E4E4E4} +\definecolor{darkred}{HTML}{BF1E0F} +\definecolor{lightred}{HTML}{F24141} +\pagecolor{papyrus} + +\usepackage{microtype} +\usepackage[breaklinks,hidelinks,pdfa]{hyperref} +\hypersetup{ + colorlinks=true, + linkcolor=darkred, + filecolor=darkred, + urlcolor=darkred, +} + + +% ? This worked for a while and then it didn't, so I wrapped \url{..} +\newcommand{\pkg}[1]{\href{https://ctan.org/pkg/#1}{\texttt{#1}}} + +% Logos and acronyms, some of them to match TUGboat commands +\RequirePackage{mflogo} % for MetaPost \MP + +\newcommand\pdfLaTeX{pdf\LaTeX} +\newcommand\PDFLaTeX{\pdfLaTeX} +\newcommand\LuaLaTeX{Lua\LaTeX} +\newcommand{\Asymptote}{\textit{Asymptote}} % as per the manual +\newcommand{\TikZ}{Ti{\em k}Z} % from TUB + +% Stuff from ltugboat.cls +\makeatletter +\def\smc{\sc} +\def\ninepoint{\small} +\DeclareRobustCommand{\SMC}{% + \ifx\@currsize\normalsize\small\else + \ifx\@currsize\small\footnotesize\else + \ifx\@currsize\footnotesize\scriptsize\else + \ifx\@currsize\large\normalsize\else + \ifx\@currsize\Large\large\else + \ifx\@currsize\LARGE\Large\else + \ifx\@currsize\scriptsize\tiny\else + \ifx\@currsize\tiny\tiny\else + \ifx\@currsize\huge\LARGE\else + \ifx\@currsize\Huge\huge\else + \small\SMC@unknown@warning + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi +} +\newcommand{\SMC@unknown@warning}{\TBWarning{\string\SMC: nonstandard + text font size command -- using \string\small}} +\newcommand{\textSMC}[1]{{\SMC #1}} +\newcommand{\acro}[1]{\textSMC{#1}\@} + +\def\tubreflect#1{% + \@ifundefined{reflectbox}{% + \TBerror{A graphics package must be loaded for \string\XeTeX}% + }{% + \ifdim \fontdimen1\font>0pt + \raise 1.75ex \hbox{\kern.1em\rotatebox{180}{#1}}\kern-.1em + \else + \reflectbox{#1}% + \fi + }% +} +\def\tubhideheight#1{\setbox0=\hbox{#1}\ht0=0pt \dp0=0pt \box0 } +\def\XekernbeforeE{-.125em} +\def\XekernafterE{-.1667em} +\DeclareRobustCommand{\Xe}{\leavevmode + \tubhideheight{\hbox{X% + \setbox0=\hbox{\TeX}\setbox1=\hbox{E}% + \lower\dp0\hbox{\raise\dp1\hbox{\kern\XekernbeforeE\tubreflect{E}}}% + \kern\XekernafterE}}} +\def\XeTeX{\Xe\TeX} +\def\XeLaTeX{\Xe{\kern.11em \LaTeX}} +\makeatother + +\def\Bib{% + \ifdim \fontdimen1\font>0pt + B{\SMC\SMC IB}% + \else + B\textsc{ib}% + \fi +} +\def\BibLaTeX{\Bib\kern.02em \LaTeX} +\def\BibTeX{\Bib\kern-.08em \TeX} + +\newcommand{\PDF}{\acro{PDF}} +\newcommand{\CTAN}{\acro{CTAN}} +\newcommand{\URL}{\acro{URL}} + +% Style I chopped out of ltugboat.cls +\usepackage{dash} + +% Section title styling +\usepackage{titlesec} +\titleformat{\section}[hang]{\color{darkblue}\large\bf}{}{0pt}{} +% \titlespacing{\section}{0pt}{2ex plus 0.1ex minus 0.05ex}{0.85ex plus 0.05ex} +\titlespacing{\section}{0pt}{*2.0}{*0.85} + +% Give paras just a bit of room +\setlength{\parskip}{0.45ex} + + +\pagestyle{empty} +\begin{document}\thispagestyle{empty} +\begin{center} + {\color{darkblue}\Large\bf A First Set of \LaTeX\ Packages} \\[1.5ex] + {\color{darkblue}\large Jim Hef{}feron} +\end{center} +\vspace{1.5ex} + +\begin{multicols*}{2} +If you are a \LaTeX{} beginner and ask, +``How do I \ldots{}\,?'' +then often you will be told that there is a package for that. +You may well next ask, +``How would I know that? +And if there is more than one package then which should I use?'' + +This list covers most of what +beginners want to do. +Its goal is to cite one +package in each area that is capable and reliable, and +that is in +% \textsf{Mac}\kern-0.35pt\TeX, +Mac\kern-0.35pt\TeX, +MiK\TeX, and \TeX\ Live. +(There are some extra comments in parentheses that +often come up along with the recommendations.) + + + +% ============================== +\section{Introduction} +For \LaTeX{} users, the canonical archive is +the Comprehensive \TeX{} Archive Network, +\href{https://ctan.org}{\color{darkblue}\CTAN}. +It has the latest official versions of +the packages in the distributions, +with documentation. +And, \href{https://ctan.org/topics/cloud}{\color{darkblue}searching by topic} +is very handy. + +You can also see the package documentation installed on +your computer by typing +\verb!texdoc <packagename>! % space too wide? +in a terminal window. + +Before the list, one more note. +If you are writing for a journal or +institution that has its own package then of course you should +use that. +Look on their web page and on \CTAN. + + + +% =================================== +\section{Every document} +To change page size, margins, and orientation, use +\pkg{geometry}. +Get multiple columns with \pkg{multicol}. + +Any document containing significant amounts of mathematics should use +the American Mathematical Society's packages +\pkg{amsmath} +and +\pkg{amssymb}. +I also use \pkg{amsthm} +for producing theorem environments. +Notes: (1)~\pkg{amssymb} inputs \pkg{amsfonts} so you don't need to load +the latter, +(2)~many authors also use the caligraphic characters in \pkg{rfsf}, +(3)~get bold math symbols with \pkg{bm}, +(4)~load \texttt{amsthm} after \texttt{amsmath}, +and (5)~don't load \texttt{amsmath} directly, instead get it by loading +\pkg{mathtools} for some useful improvements. + +You can toss in +\pkg{microtype}. +My eye can't spot the improvements but I appreciate that +it means there are fewer awkward lines. + + +% =================================== +\section{Inside a document} +To tweak lists, use \pkg{enumitem}. + +Enhance captions with +\pkg{caption} +and control floating environments with +\pkg{float}. +(In particular, this package provides the option `\texttt{H}' +to override automatic float placement and put something +exactly where you ask.) + +Get hyperlinks and turn references into links with +\pkg{hyperref} +(this should be the last or next to last package +that you load). +Make cross-references say `Theorem~1.2' instead of just `1.2' +with the one-r-ed \pkg{cleveref} +(load it after \texttt{hyperref}). +Have \acro{URL}'s and file paths that can linebreak with +\pkg{url}. +(If you use \texttt{hyperref} then note that it has its own +commands for the \texttt{cleveref} and \texttt{url} functions.) + +I do code listings with +\pkg{listings}, +although \pkg{minted} is also great. +Make single quotes inside verbatim text come out correctly with +\pkg{upquote}. + +(A tangent:~copy and paste for computer code listings would be especially +convenient. +This is a start for the \texttt{listings} package. +\begin{lstlisting} +\lstset{basicstyle = \ttfamily, + keepspaces=true, + columns=fullflexible} +\end{lstlisting} +But it is not a full solution. +The results depend on the \PDF{} viewer and +worse, if your code line begins with +blank spaces then after copy and paste those spaces are gone.) + +If you use Python, +\pkg{pythontex} +will show code listings, but it also allows you to execute +Python and put the results in your output. +Do the same for +the \textit{Sage} mathematics software with \pkg{sagetex}, +and similar systems exist for R, Haskell, and Scheme. + +There are many package that add table capabilities such as +multirow entries and breaking across pages. +I most often use \pkg{array}, which lets you define your own column +types. +To handle units, +use \pkg{siunitx} +(which also has a table column type for aligning on a decimal point). + +Make boxes that are colored or framed, such as boxes for theorems, +with +\pkg{tcolorbox}. + +% Finally, when developing a document I often want some filler text. +% I use +% \pkg{lipsum}. + + +% =================================== +\section{Graphics and color} +To include graphics and do simple manipulations such as resizing, +use \pkg{graphicx}. +Use the \acro{JPG} format for photos, +\acro{PNG} for other kinds of raster graphics, +and \PDF{} for vector graphics. +If your graphic is in another format then convert it to one of these three. +(Usually you give the file name without the extension, +as with \verb!\includegraphics{graph}!.) +Include parts of a \PDF{} document with +\pkg{pdfpages}. +Include video or sound using +\pkg{media9}. + +For colors, use +\pkg{xcolor} +(although the documentation can be hard to make out). + +To make plots and graphics, I use +\href{https://asymptote.sourceforge.io/}{\Asymptote{}}, +a development of \MP{} with three dimensional +constructs. +However, many people instead draw graphics +inside the document with +\href{https://ctan.org/pkg/pgf}{\TikZ}. + + +\section{Front and back matter, headers, footers} +To style chapter and section titles, use +\pkg{titlesec}. +For page headers and footers, reach for +\pkg{fancyhdr}. +You can tweak the format of tables of contents, lists of figures, etc., +with +\pkg{tocloft}. + +Write exercise answers to an external file so that you can read them in +later with +\pkg{answers}. +I like footnotes at the page bottom so I use +\pkg{footmisc} +(but I had to hack to change the space between a footnote mark and +the footnote). +Make an index with +\pkg{makeindex}. + +Bibliographies are a thorny area. +Often you have strict requirements, such as from the +\pkg{MLA}. +\CTAN{} is a big help here; check out the many styles for both +\href{https://ctan.org/topic/bibtex-sty}{\BibTeX} +and +\href{https://ctan.org/topic/biblatex}{\BibLaTeX}. + + + + +\section{Special documents} +Make exams and problem sets with the +\pkg{exam} class. + +There are many, many resume and CV packages. +Start with \acro{CTAN}'s +\href{https://ctan.org/topic/cv}{\textit{cv}} topic. + +To make presentations, use the +\pkg{beamer} class. +(But with this package you are entering another world, where many of the +packages discussed here do not work. +For example, section title styling happens via a completely +different mechanism.) + + + +\section{Fonts and engines} +To see options besides the default Computer Modern fonts, +visit the +\href{https://www.tug.org/FontCatalogue/}{\LaTeX\ Font Catalogue}, +which includes copy and paste code to make each one work. + +Beyond that list, you can also use any font that your computer has +(which usually works well only if your document +does not have much mathematics). +To convert \LaTeX{} source to \PDF{} there are +three programs, called engines. +Most people use \PDFLaTeX. +The \XeLaTeX{} engine and the \LuaLaTeX{} engine can leverage +the \pkg{fontspec} +package to use your system's fonts. +(A word about the preprint site \texttt{arXiv.org}. +If your document was produced with \XeLaTeX{} or \LuaLaTeX{} then +you can only submit a \PDF, not the document source.) + +\LaTeX{} now defaults to UTF-8 encoded input on all three engines. +Use \pkg{babel} for internationalization, such as changing the +the title of the abstract or the bibliography. + +\vspace*{2ex} +\noindent{\color{lightblue}\rule{\linewidth}{0.4pt}} + +\section{Feedback?} +Contact me via +\href{https://hefferon.net}{\color{lightblue}\texttt{hefferon.net}}. +(This version is from \today.) +% The source is at +% \href{https://gitlab.com/jim.hefferon/latexpackages}{\color{lightblue}my GitLab repository}.) +\end{multicols*} + +\end{document} |