# Taking user input during compile

Deeply inspired by Paulo Cereda's answer on the ways TeX can be used apart from document creation. If you haven't seen the program mentioned: it's a Reversi TeX game that during the compile asks the user for the next move in the game and provides feedback. At the end the whole game is produced as a dvi.

Immediately practical uses of this popped up: Asking users for layout, colors, language. So on to terra incognita!

I tried to dissect the Reversi game, but it's not written for readability. I searched around, but user input to TeX programs is not an everyday thing.

How do I take input from the user compiling the document?

For example, I could ask a user for their name, and then print "Hello, [user's name]".

Update 1: I've now stumbled upon the \read macro, and it seems to be on the way, but it isn't really what I want.

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}

\begin{document}

\end{document}


Update 2: David Carlisle pointed me to makebst a program to generate bibTeX styles. I'm looking into the source.

-

LaTeX provides the command \typein[var]{message} that should do what you're looking for:

\documentclass{article}
\begin{document}
\typein[\name]{What's your name? } % take user input
Hello \name!
\end{document}


There's also the sibling command \typeout{message} to output text on the console.

-

From makebst I found this code that seems to work in TeX.

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}

\def\defpar{\par}
\def\remblk#1 @@{#1}