Difference between revisions of "Compound words"
(I went looking for the optional hyphen I know I've used before and didn't find anything in the wiki, so I pretty much copied what's in the big manual in 7.2 (in my not-so-new version).) |
(Make examples smaller.) |
||
Line 9: | Line 9: | ||
<context source="yes"> | <context source="yes"> | ||
+ | \setuppapersize[A5] | ||
\setuphyphenmark[sign=wide] | \setuphyphenmark[sign=wide] | ||
Line 17: | Line 18: | ||
<context source="yes"> | <context source="yes"> | ||
+ | \setuppapersize[A5] | ||
\setuphyphenmark[sign=normal] | \setuphyphenmark[sign=normal] | ||
intra||word | intra||word | ||
Line 29: | Line 31: | ||
<context source="yes"> | <context source="yes"> | ||
+ | \setuppapersize[A5] | ||
a |<|as explained below|>| conflirtaneous \unknown | a |<|as explained below|>| conflirtaneous \unknown | ||
</context> | </context> | ||
Line 43: | Line 46: | ||
<context> | <context> | ||
+ | \setuppapersize[A5] | ||
\def\ShowComposed #1 | \def\ShowComposed #1 | ||
{\handletokens#1\with\type\VL#1\VL\hyphenatedword{#1}} | {\handletokens#1\with\type\VL#1\VL\hyphenatedword{#1}} | ||
− | \starttable[|l|l|l|] | + | \starttable[|l|l|l|]\setuppapersize[A5] |
\HL | \HL | ||
\VL \bf input \VL \bf normal \VL \bf hyphenated \VL\SR | \VL \bf input \VL \bf normal \VL \bf hyphenated \VL\SR | ||
Line 63: | Line 67: | ||
</context> | </context> | ||
− | == Indicating hyphenation | + | == Indicating hyphenation patterns manually / optional hyphens == |
− | If you have | + | If you have a few foreign words in your text, or simply a few unusual ones, they may hyphenate incorrectly but not be worth invoking a different {{cmd|language}} for. You can define ad-hoc hyphenation patterns with the command {{cmd|hyphenation}}: |
<texcode> | <texcode> | ||
Line 71: | Line 75: | ||
</texcode> | </texcode> | ||
− | If you just need to fix a single word, you can add an optional hyphen (hyphenation hint) with | + | If you just need to fix a single word, you can add an optional hyphen (hyphenation hint) with {{cmd|-}}: <code>kai\-vos\-auk\-ko</code>. |
== Enabling hyphenation on hyphens for composed words globally == | == Enabling hyphenation on hyphens for composed words globally == | ||
− | + | This is possible in MkIV with the following command: | |
<texcode> | <texcode> | ||
Line 81: | Line 85: | ||
</texcode> | </texcode> | ||
− | + | This is equivalent to typing each composed word as <code>composed|-|word</code>. It also sets the characters '+', '/', '(', and ')' as good breakpoints inside composed words. The slash must be typed verbatim, though, not as {{cmd|slash}} or {{cmd|backslash}}. | |
− | It | ||
− | < | + | <context mode=mkiv source=yes> |
+ | % mode=mkiv | ||
% mkiv only | % mkiv only | ||
+ | |||
+ | \setuppapersize[A6] | ||
\setbreakpoints[compound] | \setbreakpoints[compound] | ||
+ | \setupwhitespace[line] | ||
− | + | love/hate/play/run/love/hate/play/run/love/hate/play/run/love/hate/play/run | |
− | love | + | love(hate(play(run(love(hate(play(run(love(hate(play(run(love(hate(play(run |
− | love | + | love-hate-play-run-love-hate-play-run-love-hate-play-run-love-hate-play-run |
− | love | + | love+hate+play+run+love+hate+play+run+love+hate+play+run+love+hate+play+run |
− | + | love)hate)play)run)love)hate)play)run)love)hate)play)run)love)hate)play)run | |
− | + | </context> | |
− | |||
− | |||
− | </ | ||
[[Category:International]] | [[Category:International]] |
Revision as of 12:24, 29 June 2012
Words consisting of two separate words are often separated by an intra word dash, as in x-axis. This dash can be placed between two | characters, for example |-|.
When || is typed, the default intra word dash is used, which is . You can configure this with \setuphyphenmark.
Valid values are normal
and wide
.
The default sign is a combination of two hyphens:
\setuppapersize[A5] \setuphyphenmark[sign=wide] intra||word
To get a normal sign you could set this with the normal
value (ConTeXt 2008.09.16 or later).
\setuppapersize[A5] \setuphyphenmark[sign=normal] intra||word
The || is also used in word combinations like (intra)word, which is typed as (intra|)|word. The mechanism is not foolproof but it serves most purposes. In case the hyphenation is incorrect you can hyphenate the first word of the composed one by hand: (in\-tra|)|word.
Another use of || is the processing of subsentences. The symbol that surrounds a subsentence varies depending on the current language settings, as controlled by \setuplanguage. When you use |<| and |>| to indicate the subsentence, the proper symbol will be used automatically.
\setuppapersize[A5] a |<|as explained below|>| conflirtaneous \unknown
The main reason behind this mechanism is that TeX doesn’t really know how to hyphenate composed words and how to handle subsentences. TeX know a lot about math, but far less about normal texts. Using this command not only serves consistency, but also makes sure that TeX can break compound words at the right places. It also keeps boundary characters at the right place when a breakpoint is inserted.
The table below is an extended version of the table in the "big manual". In the third column, you see what the possible line breaks in the word would be, and the output that would come from that.
Indicating hyphenation patterns manually / optional hyphens
If you have a few foreign words in your text, or simply a few unusual ones, they may hyphenate incorrectly but not be worth invoking a different \language for. You can define ad-hoc hyphenation patterns with the command \hyphenation:
\hyphenation{hää-yö-aie}
If you just need to fix a single word, you can add an optional hyphen (hyphenation hint) with \-: kai\-vos\-auk\-ko
.
Enabling hyphenation on hyphens for composed words globally
This is possible in MkIV with the following command:
\setbreakpoints[compound]
This is equivalent to typing each composed word as composed|-|word
. It also sets the characters '+', '/', '(', and ')' as good breakpoints inside composed words. The slash must be typed verbatim, though, not as \slash or \backslash.
% mode=mkiv % mkiv only \setuppapersize[A6] \setbreakpoints[compound] \setupwhitespace[line] love/hate/play/run/love/hate/play/run/love/hate/play/run/love/hate/play/run love(hate(play(run(love(hate(play(run(love(hate(play(run(love(hate(play(run love-hate-play-run-love-hate-play-run-love-hate-play-run-love-hate-play-run love+hate+play+run+love+hate+play+run+love+hate+play+run+love+hate+play+run love)hate)play)run)love)hate)play)run)love)hate)play)run)love)hate)play)run