Length commands

15.5.2 Length commands

While a counter contains integers, a length command contains a real number and a dimensional unit.

L A TEX recognizes many different dimensional units. We list five absolute units: cm centimeter

in inch pc pica (1 pc = 12 pt) pt point (1 in = 72.27 pt) mm millimeter

and two relative units: em, approximately the width of the letter M in the current font ex, approximately the height of the letter x in the current font

L A TEX defines many length commands. For instance, Section 4.1 of The L A TEX Companion, 2nd edition [46] lists 17 length commands for page layout alone. You can

find some of them in Figure 10.4. A list environment sets about a dozen additional length commands (see Figure 15.2). Length commands are defined for almost every

aspect of L A TEX’s work, including displayed math environments—a complete list would probably contain a few hundred. Many are listed in Leslie Lamport’s L A TEX: A Docu- ment Preparation System, 2nd edition [43] and in The L A TEX Companion, 2nd edition [46]. Many more are hidden in packages such as amsmath.

404 Chapter 15 Customizing L A TEX The most common length commands are:

\parindent, the amount of indentation at the beginning of a paragraph \parskip, the extra vertical space inserted between paragraphs \textwidth, the width of the text on a page

A more esoteric example is \marginparpush, the minimum vertical space between two marginal notes. Luckily, you do not have to be familiar with many length com- mands because L A TEX and the document class set them for you.

Defining new length commands You can define your own length commands. For example,

\newlength{\mylength} makes \mylength a new length command with a value of 0 points. Note that while

you have to type \newcounter{counter}

to get a new counter, typing \newlength{mylength} results in an error message such as

! Missing control sequence inserted. <inserted text>

\inaccessible

l.3 \newlength{mylength} Setting length

The \setlength command sets or resets the value of a length command. So \setlength{\textwidth}{3in} creates a very narrow page. The first argument of \setlength must be a length com-

mand, not simply the command name, that is \setlength{textwidth}{3in} % Bad is incorrect. The second argument of \setlength must be a real number with a di-

mensional unit, for instance, 3in, and not simply a real number. In other words, \setlength{\textwidth}{3} % Bad is also incorrect.

15.5 Numbering and measuring 405

Tip

A common mistake is to type a command such as \setlength{\marginpar}{0} Instead, type \setlength{\marginpar}{0pt} Always be sure to include a dimensional unit.

The \addtolength command adds a quantity to the value of a length command. For instance,

\addtolength{\textwidth}{-10pt} narrows the page width by 10 points.

If you define \newlength{\shorterlength}

\setlength{\shorterlength}{\mylength} \addtolength{\shorterlength}{-.5in}

then \parbox{\shorterlength}{...} always typesets its second argument in a box 1/2 inch narrower than the parboxes set to be of width \mylength.

When L A TEX typesets some text or math, it creates a box. Three measurements are used to describe the size of the box:

the width the height, from the baseline to the top the depth, from the baseline to the bottom

as illustrated in Figure 15.1. For instance, the box typesetting “ aa” has a width of 10.00003 pt, a height of 4.30554 pt, and a depth of 0 pt. The box typesetting “ ag” has

Figure 15.1: The measurements of a box.

406 Chapter 15 Customizing L A TEX the same width and height, but a depth of 1.94444 pt. The box “ Ag” (see Figure 15.1)

has a width of 12.50003 pt, a height of 6.83331 pt, and a depth of 1.94444 pt. The commands

\settowidth \settoheight \settodepth

each take two arguments. The first argument is a length command, the second is text (or math) to be measured by L A TEX. The corresponding measurement of the box in which the second argument is typeset is assigned to the length command in the first argument. For example, if \mylength is a length command, then

\settowidth{\mylength}{Ag} assigns 12.50003 pt to \mylength. It should be clear from this example how the

\phantom and \hphantom commands (see Section 5.8.1) are related to this command. To perform more complicated arithmetic with length commands, use the calc package.

Rubber lengths In addition to rigid lengths, such as 3in, L A TEX can also set rubber lengths, that is,

lengths that are allowed to stretch and shrink. Here is an example: \setlength{\stretchspace}{3in plus 10pt minus 8pt} Assuming that \stretchspace is a length command, this command assigns it a value

of 3 inches that can stretch by 10 points or shrink by 8 points, if necessary. So a box of width \stretchspace is 3 inches wide, plus up to 10 points, or minus up to 8 points.

Stretchable vertical spaces are often used before and after displayed text environ- ments. L A TEX adjusts these spaces to make the page look balanced. An example can be found in Section 15.1.7. \medskipamount is defined as

6.0pt plus 2.0pt minus 2.0pt See Section 15.6.3 for more examples.

The \fill command is a special rubber length that can stretch any amount. The stretching is done evenly if there is more than one \fill present. See the second example of brand-new environments in Section 15.2.5.

Dokumen yang terkait

c. Bridging Teknik memanjat pada celah vertikal yang lebih besar (gullies). Caranya dengan menggunakan kedua tangan dan kaki sebagai pegangan pada kedua celah tersebut. Posisi badan mengangkang kaki sebagai tumpuan dibantu juga tangan sebagai penjaga kese

0 1 10

2. Marah: adalah kunci setiap kejahatan. Nabi saw. telah berpesan pada seseorang untuk menjauhi sikap marah dengan sabda beliau: "Janganlah engkau marah". Beliau mengulanginya berkali-kali. (H.R Bukhari). - Kebersihan Hati

2 5 14

Object Oriented Programming dengan Delphi (

1 4 75

E volusi dan aplikasi sistem informasi berbasis komputer

1 8 18

b. Data Manipulation Language (DML) : Digunakan untuk memanipulasi data dengan menggunakan perintah : select, - SISTEM BASIS DATA 1.rar (7,386Kb)

1 3 15

Hubungan Pola Asuh Orang Tua dan Kesiapan Psikologis Anak dengan Kebersihan Toilet Traning pada Anak Usia Prasekolah di Paud Ab-Arisalah Kota Lubuklinggau

0 1 8

Hubungan Pengetahuan dsn Sikap dengan Tindakan Hygiene Penjual makanan Jajanan di Lingkungan Sekolah Dasar Kaamatan Baturaja Timur Kabupaten Ogan Komering UIU Tahun 2013 A. Gani

1 3 14

Faktor faktor yang berhubungan dengan manfaatan Posyandu lansia oleh kelompok usia lanjut didesa Kemalara dalam wilayah kerja Puskesmas Kemalaraja OKU Tahun 2013. Saprianto, M.Kes

3 3 21

Korelasi umur, pekerjaan, dan keberadaan kontainer dengan kejadian penyakit malaria di desa simpang Martapura wilayah Kabupaten Ogan Komering Ulu Selatan tahun 2014 – A. Gani

0 0 18

Pengaruh Ekstrak Daun Jambu Biji (Psidiu Guajava Linn) dan Ekstrak daun Teh Hijau (Camelia Sinensis) terhadap Pertumbuhan Escherichia Coli In Vitro dan Perbandingannya dengan Kotrimoksazol

2 16 20