Difference between revisions of "Command/ctxcommand"

From Wiki
Jump to navigation Jump to search
m
m
Line 18: Line 18:
  
 
== Description ==  
 
== Description ==  
To quickly access Lua commands in the {{code|command}} table, you can write e.g.
+
To quickly access Lua commands in the {{code|command}} table.
 +
 
 +
  \def\ctxcommand      #1{\directlua{commands.#1}} % saves tokens 
 +
 
 +
You can write e.g.
 
<texcode>
 
<texcode>
 
\ctxcommand{doifelse(\userpage < 10)}{early page}{later page}
 
\ctxcommand{doifelse(\userpage < 10)}{early page}{later page}

Revision as of 11:43, 30 November 2012

\ctxcommand

Syntax

\ctxcommand{...}
{...} lua command from in the command table

Description

To quickly access Lua commands in the command table.

 \def\ctxcommand      #1{\directlua{commands.#1}} % saves tokens  

You can write e.g.

\ctxcommand{doifelse(\userpage < 10)}{early page}{later page}

instead of

\ctxlua{command.doifelse(\userpage < 10)}{early page}{later page}

.

Example

\ctxcommand{doifelse(\userpage < 10)}{early page}{later page}

\ctxcommand vs. \cldcommand

  A
  \ctxlua{commands.doif(true)}{one}
  B
  \cldcommand{doif("a","a","two")}
  C
  \ctxcommand{doif(true)}{three}
  D

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: