Fonts, Scope, and Symbols
(URL: http://www.cs.cornell.edu/Info/Misc/LaTeX-Tutorial/Fonts.html)Since LaTeX is a formatter, all changes in the format of text must be expicitly expressed. In addition, some characters that you may want to use in text have been reserved for use by LaTeX, so they have to be input as special characters. These formatting details in LaTeX are accomplished by control sequences.
Fonts
To change the font type or font size in a LaTeX document, you use one of the following control sequences.\it
- italics typeface\sl
- slanted typeface\bf
- boldface typeface\sf
- san serif typeface\tt
- typewriter typeface\rm
- normal (roman) typeface\em
- roman or italics typeface\large
- bigger type\Large
- even bigger type\small
- smaller type\normalsize
- normal size
\large
will give you larger text.
However, if you are working in 12pt type size, you have to use
\Large
to generate a larger type size.
Note that not all of the typefaces above can be expressed in
html, but you will see the results in your output.
Modify the file provoke.tex so that the first "very" is emphasized and the second is in boldface then preview the output.
and here's the dvi output.
Don't forget that if you change a font, you must change it again to get back to the default font. In addition, spaces after a command name are always ignored. The solution is to put spaces before command names, as in:
...``It's \em very \rm provoking,'' Humpty Dumpty said ...
Modify the file provoke.tex so that the first "very" is quite large and bold. Then make the second quotation all smaller except for the word "very" which should be normal sized text but boldfaced. Also try making "egg" emphasized. Here's what I mean.
Scope
Rather than changing a font then having to change it back, you can specify a scope for a font change. Braces { } are used to limit scope. In the following, italics are begun immediately following the opening brace { and stop immediately following the ending brace }. This is sometimes called a group in LaTeX.{\it text}
Change the file provoke.tex to use braces to change a font rather than explicitly switching back to the correct font.
and here's the dvi output.
Symbols
Most letters and symbols are easy in LaTeX, but some characters are reserved for LaTeX commands, i.e., braces { }. LaTeX requires control sequences to format some symbols in text. For the most part, a control sequence is a back slash followed by the desired symbol or its designator. Here's some examples,-
\& &
- ampersand -
\{ {
- left brace -
\} }
- right brace -
\$ $
- dollar sign -
\% %
- percent sign -
\# #
- number sign -
\_ _
- underscore -
\-- -
- hyphen -
\--- -
- dash -
\--- -
- (em) dash -
\`` "
- open quotes -
\'' "
- close quotes
Make a file called symbols.tex, format, and preview it. The final result should look something like this.
Be wary when using symbols. For example, you will almost always get a LaTeX error if you enter
"It cost $10 to..."
because
"$" causes LaTeX to enter math mode
(discussed later). Or "The price rose 32% and..."
tells LaTeX to ignore everything on the line
after the "%". Try it if you want to see the results.
Verbatim
Some things are difficult to format (typeset) in LaTeX. For example, how do you get\begin{tabular}
?
That's simple, just use the LaTeX formatting command
\verb which is short for "verbatim."
\verb,any text,
\verb
is not
delineated by braces, but by commas. Everything between
the commas is in tt (typewriter) font and looks just as you
entered it. Also, between the delimiters, all LaTeX commands
are ignored and are printed as typed. Note that there should not
be a space between the \verb
and the first
delimiter, in this case, a comma (,).
Make a file called verbatim.tex with the following paragraph in it so that the LaTex commands appear in typewriter font in the final result:
- In LaTeX, braces { } limit the scope of certain commands,
as in
{\it text}
. Other commands, such as\verb
can use any two identical symbols.
You can also use the verbatim environment for larger pieces of text that you need to format. There are begin/end constructs to let Mosaic (or other browser) as in:
\begin{verbatim}
- :
- bunch of things
- :
\end{verbatim}
\begin{quote}
\begin{verbatim}
- :
\end{verbatim}
\end{quote}
Using the file verbatim.tex that you created above, enter the following text at the end of the file, and typeset it to look like it does here.
- The following are control sequences used in LaTeX to allow the formatting of certain reserved symbols.
-
\& &
- ampersand -
\{ {
- left brace -
\} }
- right brace -
\$ $
- dollar sign -
\% %
- percent sign -
\# #
- number sign -
\_ _
- underscore - These symbols are unpredictable, so be careful. Note that on the output the embedded \LaTeX commands are not executed.
and here's the dvi output.
If you have any questions or problems, send mail to www@cs.cornell.edu.
Last modified 19 Jan 1995 by Denise Moore (denise@cs.cornell.edu).
No comments:
Post a Comment
Thank you