Advanced L A TEX course; first session

Similar documents
Org mode (La)TEX macros for HTML and L A TEX export

CSE 150: Notation Examples

Meeting One. Aaron Ecay. February 2, 2011

M. R. C. van Dongen. ucc. LaTEX and Friends. Commands and Environments. Marc van Dongen

1. The Joy of TEX. Check out this example!

Homework # You ll want to use some LaTeX editor to edit and compile your.tex files

Package mathcmd. F. Bosisio 1997/12/20

L A TEX: Online module 2

Using L A TEX. A numbered list is just that a collection of items sorted and labeled by number.

The xargs package. Manuel Pégourié-Gonnard v1.1 (2008/03/22) 1 Introduction 1. 2 Usage 1

Sending Answers to Exercises (or Proofs of Theorems) to appendices

beginlatex /12/ : page #199

The chemcompounds package

Version v2.01, 2000/06/29

Introduction to L A TEX for MCS-236

COMP496/901: Academic Presentation and Writing Skills Using LaTeX

The optparams package

The MathType Window. The picture below shows MathType with all parts of its toolbar visible: Small bar. Tabs. Ruler. Selection.

David Helmbold, October 2005, Revised October 2007

Intro to LATEX I. Aaron Erlich POLS/CSSS 510, Why LATEX? Programming Document Structure Floats Tables Lists Math

L A TEX Class Holiday Inn Fisherman s Wharf San Francisco, CA July Cheryl Ponchin Sue DeMerritt

The hypbmsec package

1. Welcome. (1) Hello. My name is Dr. Christopher Raridan (Dr. R). (3) In this tutorial I will introduce you to the amsart documentclass.

Contents. Foreword. Examples of GeoGebra Applet Construction 1 A Straight Line Graph... 1 A Quadratic Graph... 6 The Scalar Product...

HOW TO TYPESET THESES. Using iiscthesis style for LAT E X

Lecture 04 FUNCTIONS AND ARRAYS

The ushort package. Martin Väth 2013/11/26

Introduction to MCS 220 and L A TEX

CS 189 L A TEX and Linux: Displaying Text

The svn-prov package

What is LaTeX. Is a document markup language and document preparation system for the TeX typesetting program

An Introduction to. Rado Ivanov CIS400 Senior Design Tutorial September 18, 2014

Shorter space after ellipsis

L A TEX Primer. Randall R. Holmes. August 17, 2018

The calculation environment

NCSU Linguistics Eric Wilbanks & Jeff Mielke. November 21, An open-source typesetting language used for document mark-up

Preparation of ADSA and IJDE Manuscripts

Tools for Scientific Writing with LAT E X. Johan Carlson

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary

FiNK the L A TEX2ε File Name Keeper

The svn package. Richard Lewis 25th September 2007

MITOCW watch?v=0jljzrnhwoi

L A TEX for Psychological Researchers

Introduction to L A TEX

The textcase package

An Introduction to L A T E X

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

The lips LaTeX package Chicago Manual text ellipses (Frankenstein s lips)

L A TEX. COMPSCI 111 / 111G Mastering Cyberspace: An introduction to practical computing. LaTeX. Development. Why?

CS 189 L A TEX and Linux: Document Layout and Organization

CS214 Advanced UNIX Lecture 4

Starting. Read: Chapter 1, Appendix B from textbook.

Electronic Production Guidelines

qstest.sty QuinScape Unit Test Package version

The multicap L A TEX2ε package

L A TEX E Here s the example of a X

The cybercic package

The tensor package for L A TEX2e

qstest, a L A TEX package for unit tests

The newcommand.py utility

L A TEX Tutorial. 1 Introduction. 2 Running L A TEX. J. E. Rice. May 2010

Why learning L A TEX is worth the effort

Fancy paragraph designs with the fancypar package

The rotfloat package

Some (semi-)advanced tips for LibreOffice

OUTLINES. Variable names in MATLAB. Matrices, Vectors and Scalar. Entering a vector Colon operator ( : ) Mathematical operations on vectors.

TUTORIAL 10: ARRAYS AND MATRICES. 1. Welcome. Hello. My name is Dr. Christopher Raridan (Dr. R). I want to welcome you to the L A TEX Tutorial Series.

Learning LaTeX: The Basics

Square cells: an array cooking lesson

The crush package. Jesse A. Tov This document corresponds to crush v0.2, dated 2011/07/29.

Math 395 Homework #1 Due Wednesday, April 12

A couple of things involving environments

APPM 2460 PLOTTING IN MATLAB

The handout document class

Absolute L A TEX Beginner

WYSIWYG Systems. CSCM10 Research Methodology Lecture 4 (11/2/16): A Taster of L A TEX WYSIWYM. Advantages/Disadvantages of WYSIWYG Systems

Homework # (Latex Handout) by Laura Parkinson

A Document Class and a Package for handling multi-files projects

The mcaption package

LATEX Primer. 1 Introduction (Read Me)

The L Y X Tutorial. by the L Y X Team 1. December 2, them to the LYX Documentation mailing list:

1. The Joy of TEX. Check out this example!

The tabularx package

The stdclsdv package

The lips LaTeX package Chicago Manual text ellipses (Frankenstein s lips)

Martin Scharrer Version v /09/19

TeXnicCenter v1 Beta Frank Van Puyvlde ICT for Research K.U.Leuven

altfont: Using alternative fonts

L A TEX Overview. Jiayi Liu. January 31, Colorado School of Mines

CSCM10 Research Methodology A Taster of L A TEX

The authorindex Package

WYSIWYG Systems. CSCM10 Research Methodology A Taster of L A TEX WYSIWYM. Advantages/Disadvantages of WYSIWYG Systems.

Typesetting ancient Greek using Ibycus-encoded fonts with the Babel system

The mat2doc documentation system

Implementation of Forest, a pgf/tik Z-based package for drawing linguistic trees

Math 291: Lecture 2. Justin A James. Minnesota State University Moorhead web.mnstate.edu/jamesju/

Abstract A quick intro by examples to the document preparation language L A TEX.

The asciilist package

Began as TeX, in 1982 (Knuth). Purely a typesetting tool. LaTeX added macros, maintaining TeX as it s typesetting engine (Lamport).

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09

Transcription:

Advanced L A TEX course; first session TEXniCie Jan Jitse Venselaar February 6th, 2007 1 / 20

Welcome to the Advanced L A TEX course! Nine sessions, every tuesday between 17:00 and 19:00. 2 / 20

Course overview 1 Commands & environments 2 Counters & lengths 3 Error messages 4 Test 5 Bibtex 6 Moving stuff 7 Pagestyles 8 To be decided 9 Final test 3 / 20

What are we going to do? 1 Organisation 2 User definitions 3 Packaging 4 / 20

New commands New commands may be defined or redefined under L A TEXwith the commands \newcommand{\\ name }[narg][opt]{def} \renewcommand{\ name }[narg][opt]{def} The first version is used to define a command that does not yet exist, the second version is used to redefine a command that already exists. A command name may be any combination of letters. 5 / 20

Example: command without arguments The structure x 1,..., x n often occurs in mathematical formulas. and is formed in math mode with x 1,\ldots,x n. \newcommand{\\xvec}{x 1,\ldots,x n} This definition of \xvec contains a math command (the underscore). It may only be called within math mode. So: \newcommand{\\xvec}{$x 1,\ldots,x n$} But now \xvec may only be called in text mode, and never in math mode! A trick to solve this is: \newcommand{\\xvec}{\ensuremath{x 1,\ldots,x n}} 6 / 20

Example: command with arguments We may want to write a 2,..., a 7 instead of x 1,..., x n sometimes. So let us make things variable. \newcommand{\\subvec}[3]{\ensuremath{#1 #2,\ldots,#1 #3}}} Now \subvec{a}{i}{j} produces a i,..., a j. However, \subvec{a}{ij}{kl} produces A i j,..., A k l instead of the wanted A ij,..., A kl. Why? Not enough curly brackets! Solution: \newcommand{\\subvec}[3]{ \ensuremath{#1 {#2},\ldots,#1 {#3}}} 7 / 20

Example: command with optional argument We had the following definition of \subvec, with three arguments: \newcommand{\\subvec}[3]{ \ensuremath{#1 {#2},\ldots,#1 {#3}}} If you want, you can make the first argument optional, in the following way: \newcommand{\\subvec}[3][x]{ \ensuremath{#1 {#2},\ldots,#1 {#3}}} Now \subvec{i}{j} produces x i,..., x j, while \subvec[a]{i}{j} produces a i,..., a j. 8 / 20

Spaces after commands A common mistake is forgetting an extra \ after a command, for example: \LaTeX is a typesetting language, gives: L A TEXis a typesetting language. \xspace, defined in \usepackage{xspace} fixes this. After the bulk of the command, put in \xspace and everything will be fine. \newcommand{\\texnicie}{\tex nicie\xspace} 9 / 20

New environments New environments may be defined or redefined under L A TEX with the commands \newenvironment{\ name }[narg][opt]{beg def}{end def} \renewenvironment{\ name }[narg][opt]{beg def}{end def} In the beg def you can use arguments, but in end def you cannot! 10 / 20

Example: environment with arguments (1/2) \newenvironment{\comment}[1]{ \noindent\slshape Comment: #1 \begin{quote}\small\itshape} {\end{quote}} Now \begin{comment}{anonymous} Let this be a comment.\end{comment} produces: Comment: Anonymous Let this be a comment. 11 / 20

Example: environment with arguments (2/2) You cannot use arguments in the end def. But what if we want to put the name of the person after his/her comment? There is a trick to solve this problem: \newsavebox{\comname} \newenvironment{\comment}[1]{\noindent\slshape Comment: \sbox{\comname{#1}}\begin{quote}\small\itshape} {\hspace*\fill\usebox{comname}\end{quote}} 12 / 20

More on user definitions (1/3) User definitions are scoped. Command and environment definitions made inside an environment are unknown to L A TEX outside the environment in which they were defined. User definitions may contain other user structures that are defined afterwards. The other structure needs to be defined before the first command is invoked. You have to work like this: \newcommand{\\c}{\a \B} normal text, without calling \C \newcommand{\\a}{command A} \newcommand{\\b}{command B} Now \C works without errors. 13 / 20

More on user definitions (2/3) User definitions may be nested inside one another. For example: \newcommand{\\five}{\newcommand{\\one}{i like \LaTeX} \one\one\one\one\one} Now \five produces five times the text I like L A TEX. The command \one cannot be used outside the command \five. 14 / 20

More on user definitions (3/3) If you want to provide arguments to nested commands, the symbols for the arguments need to be distinguished. The symbols for the outer definition are the normal #1,..., #9, while those for the outer one are ##1,..., ##9. For each level of nesting, the amount of # s is to be doubled. Example: \newcommand{\\five}[1]{\newcommand{\\one}[1]{\texttt{##1}} \one{#1}\one{#1}\one{#1}\one{#1}\one{#1}} 15 / 20

Dirty hacks To create multiple commands that almost do the same, you can use \@ifnextchar as follows: \newcommand{\\fancy}{\@ifnextchar*{cmd with star}{cmd without star} Other stuff} This command can then be used as follows: \fancy or \fancy* Also really useful if you want to break out of the 1 optional arguments and then required arguments box. http://tug.ctan.org/tex-archive/support/newcommand/ provides you with a handy way of doing this. 16 / 20

Structuring user definitions There are two ways to make a structured collection of your user definitions: making a package, *.sty; making a class, *.cls. A class contains information about how to turn logical structure (like \chapter) into formatting (like 18pt bold ragged right ). A package contains features independent of the class (such as color or included graphics). We will go into the details of classes and packages in a following lecture. For now, we will concentrate on making a basic package. 17 / 20

Structure of a package The outline of a class or package file is: identification the file says it is a L A TEX 2εpackage or class, and gives a short description of itself; declarations the file declares some commands and loads other files. These commands will be just those needed for the code used in the next part; options the file declares and processes its options; declarations the file does most of its work: declaring new variables, commands, and fonts, and loading other files. We will tell more about options in a next lecture, for now we will concern ourselves with the first and fourth item. 18 / 20

Identification Package files identify themselves by means of the following commands: \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{ package }[ date other information ] For example: \NeedsTeXFormat{LaTeX2e} \ProvidesPackag{latexsym}[1993/06/01 Standard LaTeX package] The date is for checking whether your version of the package is outdated. 19 / 20

Declarations (the fourth item) You can put basically everything in the declaration part of your package. However, packages are loaded in the preamble. Therefore, you cannot put anything in the package that directly generates output. Usually, this part of a package (or a class) is one long list of newcommands, newenvironments, counters (next lecture), lengths (next lecture), pagestyles (further on), etcetera, etcetera, etcetera. 20 / 20