## Terminal input/output

### `\typein`

Synopsis, one of:

    \typein{prompt-msg}
    \typein[cmd]{prompt-msg}

Print prompt-msg on the terminal and cause LaTeX to stop and wait for you to type a line of input. This line of input ends when you hit the return key.

For example, this

    As long as I live I shall never forget \typein{Enter student name:}

coupled with this command line interaction

    Enter student name:

    \@typein=Aphra Behn

gives the output ‘`... never forget Aphra Behn`’.

The first command version, `\typein{prompt-msg}`, causes the input you typed to be processed as if it had been included in the input file in place of the `\typein` command.

In the second command version the optional argument `cmd` argument must be a command name — it must begin with a backslash, \. This command name is then defined or redefined to be the input that you typed. For example, this

    \typein[\student]{Enter student name:}
    \typeout{Recommendation for \student .}

gives this output on the command line,

    Enter student name:

    \student=John Dee
    Recommendation for John Dee.

where the user has entered ‘`John Dee.`’

### `\typeout`

Synopsis:

    \typeout{msg}

Print `msg` on the terminal and in the `log` file.

This

    \newcommand{\student}{John Dee}
    \typeout{Recommendation for \student .}

outputs ‘`Recommendation for John Dee`’. Like what happens here with `\student`, commands that are defined with `\newcommand` or `\renewcommand` (among others) are replaced by their definitions before being printed.

LaTeX’s usual rules for treating multiple spaces as a single space and ignoring spaces after a command name apply to `msg`. As above, use the command `\space` to get a single space, independent of surrounding spaces. Use `^^J` to get a newline. Get a percent character with `\csname @percentchar\endcsname`.

This command can be useful for simple debugging, as here:

    \newlength{\jhlength}
    \setlength{\jhlength}{5pt}
    \typeout{The length is \the\jhlength.}

produces on the command line ‘`The length is 5.0pt`’.