# Interactive macro with \typein

I would like to allow the user to interact with the document at compilation time, for example to choose the color of hyperlinks.

For that, I created a new if and used \typein like in the following example :

\documentclass{article}
\else
\fi
\begin{document}
\section{Title}\label{one}
The section \ref{one}
\end{document}


This works, but I'm not satisfied because of the supplementary macro \cllink that isn't very necessary (I think).

I try

\newif\ifcllinks


But this doesn't work (missing \endcsname inserted).

Is it possible to make it works with some TeX hackery (\expandafter, \string, …) ?

-

No it isn't possible to make this work.

The content of \csname ... \endcsname must be fully expandable, otherwise an error is raised. However \typein makes an assignment and assignments are not expandable, but must be executed. No TeX hackery can change this.

So

\typein[\cllink]{Coloried links (true or false) ?}


it as small as it gets.

You could make the macro definition local if you don't want it global:

\begingroup
\expandafter
\endgroup


but the code wont be any shorter.

-
I'm disappointed… but however it's a nice answer. – Matsaya Mar 3 '11 at 22:12

One answer is already accepted, but I am going to throw mine out there anyhow: Why insist that the user type “true” or “false”? Here is a variant that will accept any answer starting with a lower case “y” as an affirmative, anything else meaning no:

\documentclass{minimal}
\makeatletter
\makeatother
% demo:

\ask{colored links?}