Readings This week please read nothing new, please remember you don’t have to read sections marked with a double dangerous curve sign This week we are focusing on some of the trickier portions of the macros section from last week. Specifically, we will be focusing on conditionals, and a few of the other things on pg 209 & 213.
• What is a delimited macro argument?
• What is a register, and how do you use one?
• How do the \if* commands work?
• What does \the do and when do you need to use it?
Exercise 1 (Delimiting Arguments)
Now that you know how the \proclaim macro, on pg 202, works, use a similar scheme to
design a macro for putting a heading at the top of your papers that looks like the one at the top
of the .pdf files for the weeks. There is a link at left .. If you want you can delimit the first argument with a period like the \proclaim
command, but the basic layout should be the same.
Exercise 2 (Registers)
This exercise references some earlier material from the section on chapter 15 so you may want
to review that chapter before trying this (specifically pgs. 117–121 regarding registers). In
this chapter there is a \proclaim function for making theorems, but usually theorems follow
pretty specific rules when you are typesetting new ones, such that each one in a chapter is
labeled: chapter number.theorem number like this: Theorem 2.4 would indicate the
fourth theorem in chapter 2. Write a macro that utilizes two registers chapNo and theNo
such that every time you call \theorem it automatically numbers the theorem number and
chapter number and typesets the rest of it as proclaim is defined on pg. 202. (NOTE: It
may behoove you to also make a \chapter macro as well that resets your theorem number and
changes the chapter number.)
Exercise 3 (Recursion and Conditionals )
In this exercise we are going to write a simple recursive macro. If you don’t know what recursion
is please go take a look at the wikipedia article on Recursion.
In this macro we are going to utilize two registers one to define the number at which
we want to start the recursion and one to hold our total value. The purpose of this macro is to
add all the number from our original number down to zero. So if we had our original register
at 5 the output of our function should be 15. This function will have to use conditionals to
prevent the recursion from going on infinitely and may need to use \the to expand the register
in places that TEX doesn’t expect a number. |