28.03.2013 Views

Guide to LaTeX (4th Edition) (Tools and Techniques

Guide to LaTeX (4th Edition) (Tools and Techniques

Guide to LaTeX (4th Edition) (Tools and Techniques

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

9.1.3 Moni<strong>to</strong>r input <strong>and</strong> output<br />

9.1. Processing parts of a document 211<br />

There are times when it is desirable that L AT E X write a message <strong>to</strong> the<br />

computer moni<strong>to</strong>r during processing. This can be achieved with the<br />

comm<strong>and</strong><br />

\typeout{message}<br />

where message st<strong>and</strong>s for the text that is <strong>to</strong> appear on the moni<strong>to</strong>r. This<br />

text is printed when the L AT E X processing reaches this comm<strong>and</strong>. It is also<br />

written <strong>to</strong> the transcript file, but does not appear in the processed output.<br />

If message contains a user-defined comm<strong>and</strong>, it will be interpreted<br />

<strong>and</strong> its translation appears on the moni<strong>to</strong>r. The same thing applies <strong>to</strong><br />

L AT E X comm<strong>and</strong>s. This could have dire consequences if the comm<strong>and</strong>s,<br />

either user or L AT E X, are not really printable. To print the comm<strong>and</strong> name<br />

literally, precede it with the comm<strong>and</strong> \protect.<br />

The comm<strong>and</strong><br />

\typein[\com name]{message}<br />

also writes the message text <strong>to</strong> the moni<strong>to</strong>r, but then it waits for the<br />

user <strong>to</strong> enter a line of text from the keyboard, terminated by typing the<br />

〈return〉 key. If the optional argument \com name is missing, the line of<br />

text is inserted directly in<strong>to</strong> the processing. In this way, one could, for<br />

example, reuse the same text for a letter for several addressees, entering<br />

the name each time from the keyboard. Suppose the text contains<br />

Dear \typein{Name:}\\ ...<br />

then what appears on the moni<strong>to</strong>r is:<br />

✎<br />

Name:<br />

☞ At this point, one enters the name of the<br />

recipient. If on successive processings<br />

‘George’, ‘Fred’, <strong>and</strong> ‘Mary’ are entered, the<br />

result will be a set of identical letters dif-<br />

\@typein=<br />

fering only in their salutations as ‘Dear<br />

✍<br />

✌ George’, ‘Dear Fred’, <strong>and</strong> ‘Dear Mary’.<br />

If the \typein comm<strong>and</strong> contains the optional argument \com name,<br />

this is treated the same as<br />

\typeout{message} \newcomm<strong>and</strong>{\com name}{entered definition}<br />

In this case the definition is s<strong>to</strong>red under the comm<strong>and</strong> name \com name<br />

interactively <strong>and</strong> may be invoked <strong>and</strong> executed in the rest of the document<br />

like any other L AT E X comm<strong>and</strong>.<br />

With some experience in L AT E X methodology, it soon becomes obvious<br />

that interactive processing with the \typein comm<strong>and</strong> can be very<br />

practical. For example, if the preamble contains<br />

\typein[\files]{Which files?}<br />

\includeonly{\files}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!