Difference between revisions of "Command/iftrialtypesetting"

From Wiki
Jump to navigation Jump to search
(Created page with "Documentation for \iftrialtypesetting")
 
 
Line 22: Line 22:
 
Using <tt>\iftrialtypesetting</tt> as a test for non-final typesetting passes is especially useful inside TABLEs. If a  counter is incremented inside of a TABLE cell, it may be incremented multiple times accidentally while TABLE tries to figure out the required column widths.
 
Using <tt>\iftrialtypesetting</tt> as a test for non-final typesetting passes is especially useful inside TABLEs. If a  counter is incremented inside of a TABLE cell, it may be incremented multiple times accidentally while TABLE tries to figure out the required column widths.
  
There are other situations where <tt>\iftrialtypesetting\else</tt> is useful, but TABLE is the most common case.
+
There are other situations where a conditional of the form <tt>\iftrialtypesetting\else ... \fi</tt> is useful, but making sure counters are not incremented too often is a typical application.
 
</cd:description>
 
</cd:description>
<cd:examples><cd:example title="Simple example">\definecounter[EventCount]
+
<cd:examples><cd:example title="Simple example"><context source="yes">
 +
\definecounter[EventCount]
  
Event: \rawcountervalue[EventCount]
+
Before table: \rawcountervalue[EventCount]
  
 
\startTABLE[|p|]
 
\startTABLE[|p|]
\NC Event: \rawcountervalue[EventCount]
+
\NC (table here)\incrementcounter[EventCount]\NC\NR
    \incrementcounter[EventCount]
 
\NC\NR
 
\NC Event: \rawcountervalue[EventCount]
 
    \iftrialtypesetting\else\incrementcounter[EventCount]\fi
 
\NC\NR
 
 
\stopTABLE
 
\stopTABLE
</cd:example></cd:examples>
+
 
 +
After table: \rawcountervalue[EventCount]
 +
 
 +
\blank
 +
Before table: \rawcountervalue[EventCount]\\
 +
 
 +
\startTABLE[|p|]
 +
\NC (table here)\iftrialtypesetting\else\incrementcounter[EventCount]\fi \NC\NR
 +
\stopTABLE
 +
 
 +
After table: \rawcountervalue[EventCount]
 +
</context></cd:example></cd:examples>
 
<cd:notes></cd:notes>
 
<cd:notes></cd:notes>
 
<cd:seealso>
 
<cd:seealso>

Latest revision as of 13:42, 8 May 2024


\iftrialtypesetting

Summary

The command \iftrialtypesetting is a test for non-final typesetting passes

Settings

\iftrialtypesetting ... \else ... \fi
... true
\elsedelimiter
... false
\fidelimiter

Description

ConTeXt sets the \iftrialtypesetting to true when it knows that the current typesetting event (box packaging) is not the final result that will be sent to the output file, but instead is some internal action that is only executed in support of another task like measuring typeset text widths.

Using \iftrialtypesetting as a test for non-final typesetting passes is especially useful inside TABLEs. If a counter is incremented inside of a TABLE cell, it may be incremented multiple times accidentally while TABLE tries to figure out the required column widths.

There are other situations where a conditional of the form \iftrialtypesetting\else ... \fi is useful, but making sure counters are not incremented too often is a typical application.

Examples

Simple example

\definecounter[EventCount]

Before table: \rawcountervalue[EventCount]

\startTABLE[|p|]
\NC (table here)\incrementcounter[EventCount]\NC\NR
\stopTABLE

After table: \rawcountervalue[EventCount]

\blank
Before table: \rawcountervalue[EventCount]\\

\startTABLE[|p|]
\NC (table here)\iftrialtypesetting\else\incrementcounter[EventCount]\fi \NC\NR
\stopTABLE

After table: \rawcountervalue[EventCount]

Notes

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: