Difference between revisions of "Command/setuplabeltext"

From Wiki
Jump to navigation Jump to search
m (Text replace - "Reference/en|" to "Commands|")
m (fix source link)
 
(15 intermediate revisions by 4 users not shown)
Line 3: Line 3:
 
|attributes=
 
|attributes=
 
}}
 
}}
 +
 +
== [[Help:Reference|Syntax]] (autogenerated) ==
 +
<syntax>setuplabeltext</syntax>
  
 
== [[Help:Reference|Syntax]] ==
 
== [[Help:Reference|Syntax]] ==
Line 14: Line 17:
 
   </tr>
 
   </tr>
 
   <tr valign="top" class="second">
 
   <tr valign="top" class="second">
     <td class="cmd">[[Reference/en/keyword:name|name]]</td>
+
     <td class="cmd">[[Command/keyword:name|name]]</td>
     <td>[[Reference/en/value:text|text]] </td>
+
     <td>[[Command/value:text|text]] </td>
 
   </tr>
 
   </tr>
 
</table>
 
</table>
 
  
 
== Description ==  
 
== Description ==  
  
 +
In some cases ConTeXt generates text labels automatically; for example,
 +
the word ''Figure'' is generated automatically when a caption is placed
 +
under a figure. These kind of words are called label texts. Labels are
 +
set with the command {{cmd|setuplabeltext}}, and retrieved with the
 +
command {{cmd|labeltext}}. They follow the language set with
 +
{{cmd|mainlanguage}}, not the local bits of different language that are
 +
set with {{cmd|language}}.
  
 +
'''NB''' The ''option parser'' for the command {{cmd|setuplabeltext}}
 +
is [http://www.ntg.nl/pipermail/ntg-context/2012/067585.html known] to
 +
behave somewhat differently from most setups, posing minor constraints
 +
on code formatting.
 +
For instance the trailing comma after an assignment, otherwise employed
 +
to delimit the value, will lead to an error here.
 +
The final option in the list needs thus to be terminated by the closing
 +
bracket.
 +
 +
<texcode>
 +
\setuplabeltext [
 +
  Nomen=nomen,
 +
  Est=est,
 +
  Omen=est,  %% <= fails!
 +
]
 +
\setuplabeltext [Nomen=nomen, Est=est, Omen=est] %% <= works
 +
\starttext
 +
\labeltext{Nomen}
 +
\labeltext{Est}
 +
\labeltext{Omen}
 +
\stoptext
 +
</texcode>
  
 
== Example ==
 
== Example ==
  
Here is an example of changing chapter and section heads.
+
Here is an example of changing section and subsection heads.
 
<context source="yes" text="results in">
 
<context source="yes" text="results in">
\setuplabeltext[en][chapter=Chapter ]
+
% English labels
\setuplabeltext[en][section=Section ]
+
\setuplabeltext[en][section=My section ] % We want a space at the end of the label
 +
\setuplabeltext[en][subsection=My subsection ]
 +
 
 +
% Dutch labels
 +
\setuplabeltext[nl][section=Mijn hoofdstuk ] % We want a space at the end of the label
 +
\setuplabeltext[nl][subsection=Mijn onderdeel ]
  
 
\def\setheadnumber#1#2{#1. #2}
 
\def\setheadnumber#1#2{#1. #2}
  
 
\setuphead
 
\setuphead
  [chapter,section]
+
  [section,subsection]
  [command=\setheadnumber]
+
  [command=\setheadnumber,
 +
  before={\blank[disable]},
 +
  after={\blank[disable]}]
  
 
\starttext
 
\starttext
\chapter{First Thoughts}
+
 
\section{First Section}
+
\section{First Thoughts}
 +
\subsection{First Subsection}
 +
\hairline
 +
 
 +
% Changing the language does not change the labels
 +
\language[nl]
 +
\section{Second Thoughts}
 +
\subsection{Second Subsection}
 +
\hairline
 +
 
 +
% To change the labels, change the main language.
 +
\mainlanguage[nl]
 +
\section{Third Thoughts}
 +
\subsection{Third Subsection}
 +
\hairline
 +
 
 +
% Retrieving a label explicity:
 +
This is the Dutch label for sections: \labeltext{section}.
 +
 
 
\stoptext
 
\stoptext
 
</context>
 
</context>
  
 +
== See also ==
 +
* {{cmd|labeltext}} to retrieve a label text.
 +
* documentation in the source: {{src|lang-lab.mkiv}}
  
 +
== Help from ConTeXt-Mailinglist/Forum ==
 +
All issues with:
 +
{{Forum|{{SUBPAGENAME}}}}
  
== See also ==
+
[[Category:Command/Languages|setuplabeltext]]
<!-- something like [[cmd:goto|\goto]] -->
 
 
 
[[Category:Commands|setuplabeltext]]
 

Latest revision as of 15:46, 8 August 2020

\setuplabeltext

Syntax (autogenerated)

\setuplabeltext[...][...=...,...]
[...]language
keyvalue
instance of label, generated by \definelabelclass


Syntax

\setuplabeltext[...][...=...]
[...] nl fr en uk de es cz ..
name text

Description

In some cases ConTeXt generates text labels automatically; for example, the word Figure is generated automatically when a caption is placed under a figure. These kind of words are called label texts. Labels are set with the command \setuplabeltext, and retrieved with the command \labeltext. They follow the language set with \mainlanguage, not the local bits of different language that are set with \language.

NB The option parser for the command \setuplabeltext is known to behave somewhat differently from most setups, posing minor constraints on code formatting. For instance the trailing comma after an assignment, otherwise employed to delimit the value, will lead to an error here. The final option in the list needs thus to be terminated by the closing bracket.

\setuplabeltext [
  Nomen=nomen,
  Est=est,
  Omen=est,  %% <= fails!
]
\setuplabeltext [Nomen=nomen, Est=est, Omen=est] %% <= works
\starttext
\labeltext{Nomen}
\labeltext{Est}
\labeltext{Omen}
\stoptext

Example

Here is an example of changing section and subsection heads.

% English labels
\setuplabeltext[en][section=My section ] % We want a space at the end of the label
\setuplabeltext[en][subsection=My subsection ]

% Dutch labels
\setuplabeltext[nl][section=Mijn hoofdstuk ] % We want a space at the end of the label
\setuplabeltext[nl][subsection=Mijn onderdeel ]

\def\setheadnumber#1#2{#1. #2}

\setuphead
 [section,subsection]
 [command=\setheadnumber,
  before={\blank[disable]},
  after={\blank[disable]}]

\starttext

\section{First Thoughts}
\subsection{First Subsection}
\hairline

% Changing the language does not change the labels
\language[nl]
\section{Second Thoughts}
\subsection{Second Subsection}
\hairline

% To change the labels, change the main language.
\mainlanguage[nl]
\section{Third Thoughts}
\subsection{Third Subsection}
\hairline

% Retrieving a label explicity:
This is the Dutch label for sections: \labeltext{section}.

\stoptext

results in

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: