TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :

\typein[\cllink]{Coloried links (true or false) ?}
\csname cllinks\cllink \endcsname
The section \ref{one}

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

I try

\csname cllinks\typein{Coloried links (true or false) ?} \endcsname

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

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

share|improve this question
up vote 3 down vote accepted

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.


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

it as small as it gets.

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

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

but the code wont be any shorter.

share|improve this answer
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:

  \begingroup \endlinechar-1 \read-1 to\answer
  {\ifx y\answer\expandafter\@ask@y\else\expandafter\@ask@n\fi}
% demo:
\ask{Answer yes or no:}{\message{[yes]}}{\message{[no]}}
\ask{And again:}{\message{[yes]}}{\message{[no]}}

The definition is a bit longer, but here is a general mechanism for asking a yes-or-no question. For your application, you could use it as

\ask{colored links?}
share|improve this answer
I have not even think to that, but it's a good idea – Matsaya Mar 3 '11 at 23:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.