8

In this post, it was mentioned that any character can be used as a delimiter using def. Is it possible to define a function with two types of delimiters?

In particular I'm looking to define an analogue to \alert in beamer but which hides text instead of displays it. My naive guess would be:

\def\hide<#1> {#2}{\color<#1>{\usebeamercolor{hidden text}} #2}

where hidden text is a predefined beamercolor of a hard-to-see color. The first argument is given by angle brackets and the second by braces. However, upon compiling this results in the error:

Illegal parameter number in definition of \hide

EDIT: My original version had the wrong syntax. I should have written,

\def\hide<#1> {#2}{\color<#1>{black}{\usebeamercolor[fg]{hidden text}{#2}}}

where the color black is a harmless place-holder which is overwritten by \usebeamercolor

JeffDror
  • 295

1 Answers1

14
\def\hide<#1> {#2}

would define a macro with one parameter delimited by < and >space but the replacement text uses #2 hence the error.

You do not mark {} for "normal" arguments so

\def\hide<#1>#2{\color<#1>{black}{\usebeamercolor[fg]{hidden text}{#2}}}

note no space after > and no {}

David Carlisle
  • 757,742
  • 2
    one could put a space after > but then it would be required. you should add an example of use. – barbara beeton Dec 14 '15 at 22:16
  • @barbarabeeton sure, if the original question had had an example I'd have updated it but since it didn't I didn't. I'm not sure \color<x>{\usebeamercolor is correct (looks a bit odd but perhaps that's Ok in beamer) But in any case that's a different question. – David Carlisle Dec 14 '15 at 22:18
  • Thanks it works perfectly. Just a comment in case anyone actually uses this for beamer purpose. I screwed up the syntax for 'color' in the question. This version seems to work though "\def\hide<#1>#2{\color<#1>{black}{\usebeamercolor[fg]{hidden text}{#2}}}", where the black is just there because you need a placeholder for color. – JeffDror Dec 14 '15 at 22:31
  • @JeffDror you could fix the color syntax in your question, and i'll do same here, will be less confusing in the archives that way. – David Carlisle Dec 14 '15 at 22:46