latex

#define latex: \ I------------------------------------------------------------------\ I------------------------------------------------------------------\ I------------------------------------------------------------------\ I /$$ /$$$$$$$$ /$$ /$$ \ I | $$ |__ $$__/ | $$ / $$ \ I | $$ /$$$$$$ | $$ /$$$$$$ | $$/ $$/ \ I | $$ |____ $$| $$ /$$__ $$ \ $$$$/ \ I | $$ /$$$$$$$| $$| $$$$$$$$ >$$ $$ \ I | $$ /$$__ $$| $$| $$_____/ /$$/\ $$ \ I | $$$$$$$$| $$$$$$$| $$| $$$$$$$| $$ \ $$ \ I |________/ \_______/|__/ \_______/|__/ |__/ \ I------------------------------------------------------------------\ I------------------------------------------------------------------\ I------------------------------------------------------------------I • descendant of tex • pro scientific document markup language • pronounced "lateK" • due to the indifference in function/block syntax while packages being state machines, and not all blocks having to be closed, there is no way to indent it right; it will be unreadable either way • the latex "community" is even more autistic than most other tech communities, this manifests as bad documentation and hyper-fixation on meaningless details, while larger pictures are overlooked — latex has a serious problem with documentation: The following is the description of the graphicx package: "\ The package builds upon the graphics package, \ providing a key-value interface for \ optional arguments to the \\includegraphics command. \ This interface provides facilities that go far beyond \ what the graphics package offers on its own. \ For extended documentation, see epslatex. \ The package is part of the latex-graphics bundle, \ which is one of the collections \ in the LaTeX ‘required’ set of packages. \ " Based on that, now tell me, what the hell does it do? OH! IT INCLUDES IMAGES? I WOULD HAVE NEVER GUESSED, I WONDER WHY! • block floating • proper multi-language hyphenation • math notation • (physical print) page optimization • horrific syntax • dependency-mixing hell • the focus on physical prints holds back e-book technology • if you wish to write a book or a scientific article, LaTeX is by far the best you can get Programs: Repositories: CLAN : "Comprehensive Latex Archive Network" (after CPAN); collection of thousands of scripts; these things make LaTeX actually ''usable'' Compilers: • used for generating output documents from latex markup {pdf} pdflatex lualatex Distibutions: • latex is very incapable without packages, distributions provide ways to manage them texlive tlmgr : "TeXLive ManaGeR"; latex package manager miktex Editors: texstudio : the recommended editor by pro-s (not me); has live previews, do use it even if you edit the source extern overleaf.com : online editor; useful if you dont have the hair to spare to install latex and its bullshit Files: .tex : latex document Commenting: • vertical-editing-lets are fucked % <...> : single line comment Commands: \<name>([<optional_arguments>]){<arguments>}+ \documentclass[a4paper,12pt]{article} \PassOptionsToPackage{defaults=hu-min}{magyar.ldf} Environments: \begin{<env>} <...> \end{<env>} • a section of markup marked to be treated specially • further marked with the leading keyword "env"; this has nothing to do with LaTeX syntax, its my own brain damage trying to classify stuff in a readable manner // ?! env center : aligns the contents horizontally on the page env minipage : emulates a sandboxed page which becomes its own atom; sort off, footnotes? work. pagecolor? nope.; Document: { <preandum> <document_body> [discarded] } Preandum: • commands which dont have an immediate visual representatition go here document_class: — the documents class determines much about what commands are available and how the compiled document will look: • available parting expressions { \chapter{}; \section{} } • available env expressions • image rendering • sensible defaults? fuck you! it must be explicitly set \documentclass[]{<class>} : defines what type of document this is book: • differentiates between left and right pages {margin sizes} \chapter{<name>} \section{<name>} \subsection{<name>} \subsubsection{<name>} article: env abstract report: env abstract draft: disables image rendering completely and inserts placeholders; this is only useful if you know you wish to insert images later on, but you dont have any of them yet, so you wish to insert the image directives, but do not want error outs on missing files • otherwise behaves like a book (i think?) letter: env letter \address{<string>} \signature{<string>} \opening{<string>} \closing{<string>} Floating: • the one feature every latexfag is very proud of • floated objects {figures} are not placed where you specify them, but rather where it is calculated they make the most typographical sense (save the most for Mr. Printerstein) • floating works perfectly fine for printed documents because the reader can usually see it on the next page and its pretty clear where his butchered paragraph will continue; however when using a pdf reader on a screen, it gets very annoying real fast Title: \maketitle : creates a title page where called; utalizes metadata set by other commands \title \author \date \tableofcontents : table of contents generated from sections defined in the body • what? you want subtitles? lol! lmao even. \documentclass{book} \title{The art of fedposting} \author{Ciarán McGlow} \date{2016} \begin{document} \maketitle \end{document} Lists: \item[] <...> : list item; used inside all list environments env enumerate : creates an ordered list (numbered) env itemize : creates an unordered list (rulletpoints) env description : creates a dictionary list \item[<name>] Special_characters: ~ : non-breaking space \, : short non-breaking space \dots : 3 dots... -- : wide '-' ^ : super script _ : lower script \\ : line break Math: $<math_sublang>$ • its '$' because printing math notation used to cost a fortune Tables: • the worse DSL ive ever seen \begin{tabular}{<style>+} (<string> (& <string>)* \\)* \end{tabular} <style>: [|]<align> l : left r : right c : center \hline \cline{<int-1>-<int-2>} \documentclass[]{book} \begin{document} \begin{tabular}{|l|r|} \hline header$_1$ & header$_2$ \\ \hline data$_1$ & data$_2$ \\ \hline \end{tabular} \end{document} Quotes: \usepackage[autostyle]{csquotes} \DeclareQuoteStyle{magyar}{,,}{''}{>>}{<<} \enquote{% muh text } Misc_builtins: \emph{<...>} : emphasise \par : starts new paragraph \textsc : "TEXT Small Capital" (for names) \LaTeX : LaTeX with offical formatted \footnote{<string>} \the : makes variable printable \- : soft hypen; override-s where a word can be split date: \year : current year \month : current month \day : current day if_false: • creates a C "#if [0|1]" like block • slightly less distracting than large comments • slightly easier to enable/disable than large comments \iftrue \iffalse \fi Packages: \usepackage[<options>]{<package_name>} • <options> are passed to the package; each defined their own • torture suicide seems to be the least painful way of managing packages • always use the following for Hungarian documents \usapackage[T1]{fontenc} Babel: • defacto language pack ○ affects • hypenation • paragraph indentation • foot notes • quotation marks Graphicx: \usepackage{graphicx} • used to include images • surpasser of "graphics" \i:cludegraphics{<path>} \graphicspath{{<path>}+} height width Xcolor: \usepackage{xcolor} Siunitx: \num{<...>} : break up \num according to babel { \num{1000000} -> 1.000.000 } Mdframed: • used for boxes which can be broken up to multiple pages Multicol: \usepackage{multicol} \[begin|end]{multicols}{<int>} Coffee_stains: \usepackage{coffeestains} • coffee stain effects on the paper \coffeestainA{alpha}{scale}{angle}{xoff}{yoff} \coffeestainB{alpha}{scale}{angle}{xoff}{yoff} \coffeestainC{alpha}{scale}{angle}{xoff}{yoff} \coffeestainD{alpha}{scale}{angle}{xoff}{yoff} \coffeestainA{0.9}{0.85}{-25}{5cm}{1.3cm} \coffeestainB{0.7}{1}{-30}{18 pt}{-135 pt} \coffeestainC{1}{1}{180}{0}{-5 mm} \coffeestainD{0.4}{0.5}{90}{3 cm}{4 cm} Listings: \usepackage{listings} • source code printer env lstlisting : source code environment \lstset{} : configures the following listing environments language=<lang> : programming language preset keywords={<string>(,<string>)+} : extra keywords to emphasize numbers=left : display line numbers keywordstyle=<style> : override-s the default bold display of all keywords Bibtex: • formal works often refer to each other • this is done by leaving reference numbers in the text and having a bibliography at the end that defines the referenced works • the bib format was invented to ease citing; it does originate from a context of working with LaTeX { @<type>{<ID> (,<key> = <value>)+ } } programs: bibtex zotero : gui for managing bibliographies extensions: .bib : bibtex file .nbib : alternative bibtex representation citation_ids: • a system to uniquely identify literaly works • many different systems exist DOI: 10.xxxx/xxxxxx • "Digital Object Identifier" • journal articles, conference papers, datasets ISBN: 978-xxxxxxxxxx • "International Standard Book Number" • books arXiv: arXiv:YYMM.XXXXX • research papers PMID: PMID: xxxxxxx • medical articles PMCID: PMCID: PMCxxxxxxx • public medical articles . ### Latex callouts ### • everything but minipages will result in a bunch of problems • fbox/framebox chimps out with wrapping color commands, so fcolorbox must be used \documentclass{book} \usepackage{xcolor,graphicx} \usepackage{afterpage} \begin{document} \fcolorbox{black}{violet!20}{ \begin{minipage}{10cm} \includegraphics[width=4mm,height=4mm]{danger.png} {\bf This is my title} This is my test callout! \end{minipage} } \end{document} • yet better, macro it \documentclass{book} \usepackage{xcolor,graphicx} \usepackage{afterpage} \newcommand{\noticecallout}[2]{ \fcolorbox{black}{violet!20}{ \begin{minipage}{10cm} \includegraphics[width=4mm,height=4mm]{danger.png} {\bf #1!} #2 \end{minipage} } } \begin{document} \noticecallout{This is my title}{This is my text callout!} \end{document} #