Latex&Friends Course in Helsinki
Total Page:16
File Type:pdf, Size:1020Kb
LATEX&friends course in Helsinki a TEX/LATEX enthusiast’s view Gaetano Zanghirati University of Ferrara, Italy in cooperation with DOMAST Doctoral School in Mathematics and Statistics Helsinki, May 2019 Cross-references LATEX’s cross-referencing mechanism is very powerful almost anything that is numbered can easily referenced (sections, figures, formulas) LATEX automatically takes care of numbering, updating it whenever necessary the commands to be used are independent of what has to be referenced \label{name} assigns the mnemonic name name of your choice to the element that has to be referenced (as long as it has a number associated with it) \ref{name} returns the right numbering associated to name, while \pageref{name} returns the corresponding page number the parameter name does not appear in the output document, but if you reference a nonexistent name, then LATEX print “??” where such a reference command appear and issues the warning LaTeX Warning: There were undefined references A course on LaTeX&friends .:. G. Zanghirati & DOMAST .:. Helsinki, May 2019 Cross-references Cross-referencing is a two steps mechanism: 1 LATEX store in an external auxiliary file( .aux) the label with the right number to be used 2 in the next compilation, LATEX reads in the right numbering from the auxiliary file and substitute the calling \ref command with such a number every time the auxiliary file is changed, LATEX displays in the console (and write out in the log file) the warning LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right the \pageref command can be used to help the reader identify the place where the referenced element is. For instance See table~\ref{tab:countries} on page~\pageref{tab:countries} the \label command must be put immediately after the number-generating command that refers to the element A course on LaTeX&friends .:. G. Zanghirati & DOMAST .:. Helsinki, May 2019 Cross-references All letters and punctuation marks can be used to form the name of a label best practice: differentiate the kind of element with the name itself. Common choices: prefix meaning prefix meaning ch: chapter eq: equation sec: section lst: code listing subsec: subsection itm: enumerated list item fig: figure alg: algorithm tab: table app: appendix Suggestion Avoid using numbers within labels! It’s much better to describe what the object is about: if you change the order of the objects, there is no need to rename all labels and their references! A course on LaTeX&friends .:. G. Zanghirati & DOMAST .:. Helsinki, May 2019 Cross-references the amsmath package introduces specialized cross-referencing commands: \eqref typesets parenthesized numbers \tag{eqnnum} allows to manually set equation numbers to the eqnnum text string you want to appear in the document. It is normally better to use labels!. Example: \tag{\ref{eqn:before}}. \numberwithin{cntrA}{cntrB} replaces the simple cntrA by cntrB.cntrA \numcases, \subnumcases for the cases env. the command \vref from varioref package has a different output according to the context, i.e., to the relative position of element and reference: if both are in the same page, it behaves exactly as \ref; if they appear in different pages, it automatically adds the page number (if they are far away from each other), or a string such as “on the facing page”, “on the next page”, “on the previous page” (if the two pages are contiguous). A course on LaTeX&friends .:. G. Zanghirati & DOMAST .:. Helsinki, May 2019 Cross-references The hyperref package provides the command \autoref: it creates a reference with additional text corresponding to the target?s type, and all of which will be a hyperlink. Example: \autoref{sec:intro} create a hyperlink to \label{sec:intro} and, if the pointed element is Section 3.4, the hyperlink would contain the text “section 3.4”, or similar \autoref* produces an unlinked prefix there exists also a cleveref package which In the preamble, they must be loaded in the sequence varioref, hyperref and cleveref to avoid conflicts A course on LaTeX&friends .:. G. Zanghirati & DOMAST .:. Helsinki, May 2019 Managing bibliographies Managing references and citations is a relevant task There are two components: the source of information and the way they are displayed in the final document The source is essentially a set of “objects” that are mentioned somewhere in the document. Each one of these objects has attributes that may or may not be relevant to typeset The displayed aspect is the visual look of the data, that is the style used to typeset the selected attributes of each object LATEX allows two ways of management embedded system: all references data are part of the document source and you explicitly take care of the visual aspect of each single object you want to appear the final document database-enabled system: the raw data are stored in one (or more) external file(s) in a form of database items, one for each object, while the look they will have in the final document is determined by “bibliography style” specifications, in the form of TEX/LATEX commands coded in a dedicated file. A course on LaTeX&friends .:. G. Zanghirati & DOMAST .:. Helsinki, May 2019 Managing bibliographies The embedded system: the bibliography data must be put inside a thebibliography environment each object is introduced in the source code by a \bibitem command, followed by the respective attributes and the style to be used to show them the argument of \bibitem is a unique alphanumerical key that will be used to cite the reference: Modern \LaTeX{} is described in Modern LATEX is described in [1]. \cite{LatexCompanion2004}. \begin{thebibliography}{9} \bibitem{LatexCompanion2004} References Frank Mittelback, Michael Goossens, [1] Frank Mittelback, Michael \textit{The \LaTeX Companion}, Goossens, The LATEXCompanion, Second Edition, Addison-Wesley, Second Edition, Addison-Wesley, Massachusetts, 2004. Massachusetts, 2004. \end{thebibliography} A course on LaTeX&friends .:. G. Zanghirati & DOMAST .:. Helsinki, May 2019 1 Managing bibliographies The embedded system: the list of references will appear in the final document exactly where you put the environment the mandatory argument of \begin{thebibliography} tells LATEX how wide the item label will be when printed. However, that the number itself is not the parameter, but the number of digits is. the bibitem key is a mnemonic label consisting of any sequence of letters, numbers and punctuation symbols (although not a comma) various strategies suggest how to assemble this mnemonic label from the reference data and there are also automatic tools available, that can do the job for you the \cite{key} command cite a reference in the text the \cite command accepts an optional argument specifying some details of that particular reference useful for the reader Example: \cite[chapter 13, pag.~757]{LatexCompanion2004} ! [1, chapter 13, pag. 757] A course on LaTeX&friends .:. G. Zanghirati & DOMAST .:. Helsinki, May 2019 Managing bibliographies multiple consecutive citations are obtained by adding more than one reference key inside the same \cite command: \cite{LatexCompanion2004,Lamport1994} ! [1, 2] which is different from \cite{LatexCompanion2004} \cite{Lamport1994} ! [1] [2] surely, the thebibliography environment can be put in a dedicated .tex file and \inputed in the source, in the point where the bibliography have to appear, but. When is the embedded system useful? If you are writing only one or two documents and aren?t planning on writing more on the same subject for a long time. It saves the time of creating a database of references that you are never going to use again. A course on LaTeX&friends .:. G. Zanghirati & DOMAST .:. Helsinki, May 2019 Managing bibliographies The Database-enabled system: it is a much more powerful and flexible solution it uses the auxiliary tool calledB IBTEX, (bundled with LaTeX) BIBTEX has been succeeded by BibLATEX, which is configurable and customizable within LaTeX syntax BIBTEX provides for the storage of all references in an external, “flat-file” database with extension .bib (BibLATEX too) This database can be referenced in anyLATEX document, and citations made to any record it contains. This is often more convenient than embedding them at the end of every document written a “centralized” bibliography source can be linked to as many documents as desired: “write once, read many!” Of course, bibliographies can be split over as many files as one wishes: this is very useful! Example: a database players.bib dedicated to players biographies and clubs.bib dedicated to teams club history documents A course on LaTeX&friends .:. G. Zanghirati & DOMAST .:. Helsinki, May 2019 Managing bibliographies There are several different ways to format lists of bibliographic references and the citations to them in the text List styles are specified in special .bst files The citation styles consist of two parts: the format of the abbreviated citation( i.e., the marker that is inserted into the text to identify the entry in the list of references) the format of the corresponding entry in the list of references, which includes full bibliographic details two main types for abbreviated citations: numbered: are numbered consecutively in order of appearance in the list of references. Consist in Arabic numerals in parentheses, square brackets, superscript, or a combination thereof (Vancouver system) textual: use the author surname and (usually) the year as the abbreviated form of the citation, which is normally fully or partially enclosed in parenthesis (Harvard system) A course on LaTeX&friends .:. G. Zanghirati & DOMAST .:. Helsinki, May 2019 Managing bibliographies Citations styles are usually selected by options to dedicated packages, such as natbib style name author name format reference format sorting plain Homer Jay Simpson #ID# by author unsrt Homer Jay Simpson #ID# as referenced abbrv H. J. Simpson #ID# by author alpha Homer Jay Simpson Sim95 by author abstract Homer Jay Simpson Simpson-1995a acm Simpson, H.