Difference between revisions of "Command/ctxcommand"

From ConTeXt wiki
Jump to navigationJump to search
(Create page in proper place)
 
 
(4 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
|attributes=
 
|attributes=
 
}}
 
}}
 +
 +
== [[Help:Reference|Syntax]] (autogenerated) ==
 +
<syntax>ctxcommand</syntax>
  
 
== [[Help:Reference|Syntax]] ==
 
== [[Help:Reference|Syntax]] ==
Line 18: Line 21:
  
 
== 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}
Line 24: Line 31:
 
instead of
 
instead of
 
<texcode>
 
<texcode>
\ctxlua{command.doifelse(\userpage < 10)}{early page}{later page}
+
\ctxlua{commands.doifelse(\userpage < 10)}{early page}{later page}
 
</texcode>
 
</texcode>
 
.
 
.
Line 31: Line 38:
 
<context source=yes mode=mkiv>
 
<context source=yes mode=mkiv>
 
\ctxcommand{doifelse(\userpage < 10)}{early page}{later page}
 
\ctxcommand{doifelse(\userpage < 10)}{early page}{later page}
 +
</context>
 +
 +
== \ctxcommand vs. \cldcommand ==
 +
<context source=yes mode=mkiv>
 +
  A
 +
  \ctxlua{commands.doif(true)}{one}
 +
  B
 +
  \cldcommand{doif("a","a","two")}
 +
  C
 +
  \ctxcommand{doif(true)}{three}
 +
  D
 
</context>
 
</context>
  
 
== See also ==
 
== See also ==
 
* {{cmd|ctxlua}}
 
* {{cmd|ctxlua}}
 +
* {{cmd|ctxcommand}}
 +
* {{cmd|cldcontext}}
 +
* {{cmd|cldcommand}}
  
 
== Help from ConTeXt-Mailinglist/Forum ==
 
== Help from ConTeXt-Mailinglist/Forum ==

Latest revision as of 17:26, 12 November 2019

\ctxcommand

Syntax (autogenerated)


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{commands.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: