diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-06-16 16:00:40 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-06-16 16:00:40 +0200 |
commit | 008292817580eba8a0f0cf83d8e2d08df8fc8c3f (patch) | |
tree | 7e47d035cc5d1f54d20f556476c439844f1956e0 /doc | |
parent | 5e668aa418d6d082446e9369ae06625b50e49943 (diff) | |
download | context-008292817580eba8a0f0cf83d8e2d08df8fc8c3f.tar.gz |
2017-06-15 22:16:00
Diffstat (limited to 'doc')
19 files changed, 1362 insertions, 28 deletions
diff --git a/doc/context/documents/general/manuals/luatex.pdf b/doc/context/documents/general/manuals/luatex.pdf Binary files differindex 25a877887..994a464dd 100644 --- a/doc/context/documents/general/manuals/luatex.pdf +++ b/doc/context/documents/general/manuals/luatex.pdf diff --git a/doc/context/documents/general/manuals/math-mkiv.pdf b/doc/context/documents/general/manuals/math-mkiv.pdf Binary files differindex 1dd24f225..d1a780689 100644 --- a/doc/context/documents/general/manuals/math-mkiv.pdf +++ b/doc/context/documents/general/manuals/math-mkiv.pdf diff --git a/doc/context/documents/general/manuals/rules-mkiv.pdf b/doc/context/documents/general/manuals/rules-mkiv.pdf Binary files differindex 6e4da3ec8..9861f76ef 100644 --- a/doc/context/documents/general/manuals/rules-mkiv.pdf +++ b/doc/context/documents/general/manuals/rules-mkiv.pdf diff --git a/doc/context/documents/general/qrcs/setup-cs.pdf b/doc/context/documents/general/qrcs/setup-cs.pdf Binary files differindex 8e0630bdc..8bd243935 100644 --- a/doc/context/documents/general/qrcs/setup-cs.pdf +++ b/doc/context/documents/general/qrcs/setup-cs.pdf diff --git a/doc/context/documents/general/qrcs/setup-de.pdf b/doc/context/documents/general/qrcs/setup-de.pdf Binary files differindex d065c0e5c..beb59aaba 100644 --- a/doc/context/documents/general/qrcs/setup-de.pdf +++ b/doc/context/documents/general/qrcs/setup-de.pdf diff --git a/doc/context/documents/general/qrcs/setup-en.pdf b/doc/context/documents/general/qrcs/setup-en.pdf Binary files differindex d5f0fd8ac..111a63128 100644 --- a/doc/context/documents/general/qrcs/setup-en.pdf +++ b/doc/context/documents/general/qrcs/setup-en.pdf diff --git a/doc/context/documents/general/qrcs/setup-fr.pdf b/doc/context/documents/general/qrcs/setup-fr.pdf Binary files differindex dc7c313e9..3dbee7679 100644 --- a/doc/context/documents/general/qrcs/setup-fr.pdf +++ b/doc/context/documents/general/qrcs/setup-fr.pdf diff --git a/doc/context/documents/general/qrcs/setup-it.pdf b/doc/context/documents/general/qrcs/setup-it.pdf Binary files differindex 5fea7e0a3..1d0d65156 100644 --- a/doc/context/documents/general/qrcs/setup-it.pdf +++ b/doc/context/documents/general/qrcs/setup-it.pdf diff --git a/doc/context/documents/general/qrcs/setup-nl.pdf b/doc/context/documents/general/qrcs/setup-nl.pdf Binary files differindex ecdc53911..f56149a34 100644 --- a/doc/context/documents/general/qrcs/setup-nl.pdf +++ b/doc/context/documents/general/qrcs/setup-nl.pdf diff --git a/doc/context/documents/general/qrcs/setup-ro.pdf b/doc/context/documents/general/qrcs/setup-ro.pdf Binary files differindex deb5378e3..ae60bf4e5 100644 --- a/doc/context/documents/general/qrcs/setup-ro.pdf +++ b/doc/context/documents/general/qrcs/setup-ro.pdf diff --git a/doc/context/sources/general/fonts/fonts/fonts-hooks.tex b/doc/context/sources/general/fonts/fonts/fonts-hooks.tex index 9be69d6b8..7ee5dc198 100644 --- a/doc/context/sources/general/fonts/fonts/fonts-hooks.tex +++ b/doc/context/sources/general/fonts/fonts/fonts-hooks.tex @@ -572,14 +572,346 @@ version.} \stopsection +\startsection[title=Extra characters] + +When \TEX\ loads a font it gets stored in an internal format. Although \LUATEX\ +can still load \TFM\ files, normally we will load font data using \LUA\ and then +pass it to \TEX. When that is done the font is basically frozen. After all, once +you entered text and that text has been processed to a sequence of glyphs, the +backend has to be sure that it can include the right data in the result. What +matters there is: + +\startitemize[packed] +\startitem the width of a glyph \stopitem +\startitem the index of a glyph in the font \stopitem +\startitem properties of a font, like its name \stopitem +\startitem all kind manipulations don't with a virtual glyph\stopitem +\stopitemize + +So, changing an already used glyph is not done. But, adding a new one should not +be a big deal. So, starting with \LUATEX\ 1.0.5 we can add characters (that +become glyphs) to a font after it got passed to \TEX. + +Of course there are some limitations to this. For instance, when \OPENTYPE\ +features are needed, you also need to extend that bit and it's not that trivial. +But adding independent special characters is no problem. Also, you can decide to +replace an already processed glyph by another one newly created with the same +dimensions but a different rendering. + +Here I'll give a few (simple) examples. First we define a helper that creates a +rule. After that we use all kind of \CONTEXT\ data structures and helpers but the +general setup is not that complicated. + +\startbuffer +\startluacode + function document.MakeGlyph(w) + local v = 655360 + local w = w*v + local h = v + local d = v/3 + return { + width = w, + height = h, + depth = d, + commands = { + { "down", d }, + { "rule", h + d, w } + }, + } + end +\stopluacode +\stopbuffer + +\typebuffer \getbuffer + +Of course, when one defines a font to be passed to \TEX\ it needs to conform to +the standard. The \LUATEX\ manual describes what parameters and other properties +have to be set. We cheat and copy the so called null font. We also create a fonts +sub table. In such a table, a reference to id zero will be resolved to the id of +the font. + +After defining the font table, we pass it to \TEX\ with \type {font,define} watch +how we also pass an already reserved id. Then we add some characters and we also +replace character 122 which is no problem because, after all, we haven't used it +yet. We just use numbers so don't think we're doing \UNICODE\ here. + +\startbuffer +\startluacode + local fontdata = fonts.hashes.identifiers + + local id = font.nextid(true) -- true reserves the id + local nf = table.copy(fontdata[0]) + + local make = document.MakeGlyph + local add = font.addcharacters + + nf.name = "foo" + nf.type = "virtual" + nf.fonts = { { id = 0 } } + nf.characters = { + [122] = make(1), + [123] = make(2), + } + + font.define(id,nf) + + fontdata[id] = nf + + local t = make(3) + nf.characters[124] = t + add(id, { + fonts = nf.fonts, + characters = { [124] = t } + }) + + local t = make(4) + nf.characters[125] = t + add(id, { + fonts = nf.fonts, + characters = { [125] = t } + }) + + local t = make(8) + nf.characters[122] = t + add(id, { + fonts = nf.fonts, + characters = { [122] = t } + }) + + interfaces.setmacro("MyDemoFontId",id) +\stopluacode +\stopbuffer + +\typebuffer \getbuffer + +\startbuffer +\def\MyDemoFont{\setfontid\MyDemoFontId} +\stopbuffer + +We also define a command to access this font: + +\typebuffer \getbuffer + +\startbuffer +{\MyDemoFont \type{[122=}\char122\type{]}} +{\MyDemoFont \type{[123=}\char123\type{]}} +{\MyDemoFont \type{[124=}\char124\type{]}} +{\MyDemoFont \type{[125=}\char125\type{]}} +\stopbuffer + +and we test this font as follows: + +\typebuffer + +This gives: + +\startlines \getbuffer \stoplines + +Next we extend an existing font and demonstrate several methods for extending a +font. First we define a font that we will patch. + +\startbuffer +\definefontfeature[myextension-one][default][myextension=1] + +\definefont[MyDemoOne][Serif*myextension-one] +\stopbuffer + +\typebuffer \getbuffer + +\startbuffer +\startluacode + local currentfont = font.current() + local fontdata = fonts.hashes.identifiers[currentfont] + local characters = fontdata.characters + local cfonts = fontdata.fonts + local addcharacters = font.addcharacters + + local make = document.MakeGlyph + + local function startextension() + statistics.starttiming() + end + + local function stopextension(n) + context.NC() context.formatted.type("\\char%s",n) + context.NC() context.char(n) + context.NC() context("%0.3f",statistics.stoptiming()) + context.NC() context.NR() + end + + context.starttabulate { "||||" } + + startextension() + for i=1000,1999 do + local t = make(3) + characters[i] = t + addcharacters(currentfont, { + fonts = cfonts, + characters = { [i] = t } + }) + end + stopextension(1500) + + startextension() + local t = { + fonts = cfonts, + characters = characters + } + for i=2000,2999 do + characters[i] = make(5) + addcharacters(currentfont, t) + end + stopextension(2500) + + startextension() + for i=3000,3999 do + characters[i] = make(7) + end + addcharacters(currentfont, { + fonts = cfonts, + characters = characters + }) + stopextension(3500) + + startextension() + local t = { } + for i=4000,4999 do + characters[i] = make(9) + t[i] = characters[i] + end + addcharacters(currentfont, { + fonts = cfonts, + characters = t + }) + stopextension(4500) + + local addcharacters = fonts.constructors.addcharacters + + startextension() + local t = { } + for i=5000,5999 do + t[i] = make(11) + end + addcharacters(currentfont, { + fonts = cfonts, + characters = t + }) + stopextension(5500) + + context.stoptabulate() +\stopluacode +\stopbuffer + +Watch how we only pass the new characters. We also need to make sure that the +table at the \LUA\ end gets updated, because we might need the data later. You +can see that not all methods are equally efficient. The last extension uses a +helper that also makes sure that the main character table at the \LUA\ end gets +updated. + +\typebuffer \start \MyDemoOne \getbuffer \stop + +\startbuffer +\startluacode + local addcharacters = fonts.constructors.addcharacters + local currentfont = font.current() + local parameters = fonts.hashes.parameters[currentfont] + + local m = metapost.simple + local f = string.formatters + ["draw fullsquare rotated %i scaled %b randomized 2bp withcolor %s"] + + local push = { "push" } + local pop = { "pop" } + + function make() + local r = parameters.size + local o = r/2 + local p1 = m("metafun",f( 0, r, "red")) + local p2 = m("metafun",f(30, r, "green")) + local p3 = m("metafun",f(60, r, "blue")) + return { + width = o + r, + height = 2*o, + depth = o, + commands = { + { "down", -o/2 }, { "right", o/2 + o }, + push, { "pdf", "origin", p1 }, pop, + push, { "pdf", "origin", p2 }, pop, + push, { "pdf", "origin", p3 }, pop, + }, + } + end + + local t = { } + for i=6000,6010 do + t[i] = make() + end + addcharacters(currentfont, { + fonts = cfonts, + characters = t + }) +\stopluacode +\stopbuffer + +In this example we use \METAPOST\ to generate a shape. There is some juggling +with dimensions and we need to shift the image in order to get a proper baseline. + +\typebuffer \start \MyDemoOne \showglyphs \getbuffer \stop + +These shapes show up as follows. We show the bounding box too: + +\startbuffer +\scale [width=\textwidth] {% + \char6000 \space + \char6001 \space + \char6002 \space + \char6003 +} +\stopbuffer + +\typebuffer \startlinecorrection \MyDemoOne \showglyphs \getbuffer \stoplinecorrection + +When defining virtual characters you need to keep in mind that there are limits to +how large a character can be. If you go too far \LUATEX\ will quit with a scale +related message. + +In \CONTEXT\ there are a couple of mechanism that were implemented when \LUATEX\ +came around that can be updated to use the tricks described here. I'm not sure if +I'll do that. After all, it works now too. The main benefit of the fact that we +can extend a font within reasonable bounds is that future mechanism can benefit +from it. + +There is one thing to keep in mind. Say that we define a font like this: + +\starttyping +\definefont[MyDemoOneX][Serif*myextension-one] +\stoptyping + +Because we already defined a font with the same size, we automatically get the characters +\type {6000} upto \type {6003}. If we don't want this and want a fresh instance, we can do: + +\starttyping +\definefontfeature[myextension-two][default][myextension=2] +\definefont[MyDemoOneX][Serif*myextension-two] +\stoptyping + +or just: + +\starttyping +\definefont[MyDemoOneX][Serif*default] +\stoptyping + +Normally this kind of hackery is not arbitrary and part of a well designed set up +so one knows what one gets. + +\stopsection + % - features % - subfonts % - outlines % - math % - hashes -\stopsection - \stopchapter \stopcomponent diff --git a/doc/context/sources/general/manuals/luatex/luatex-languages.tex b/doc/context/sources/general/manuals/luatex/luatex-languages.tex index 54a7b390d..a3790cab7 100644 --- a/doc/context/sources/general/manuals/luatex/luatex-languages.tex +++ b/doc/context/sources/general/manuals/luatex/luatex-languages.tex @@ -263,6 +263,65 @@ The word end is determined as follows: \NC adjust \NC when hyphenationbounds 2 or 3 \NC \NR \stoptabulate +\in{Figures}[hb:1] upto \in[hb:5] show some examples. In all cases we set the min +values to 1 and make sure that the words hyphenate at each character. + +\hyphenation{o-n-e t-w-o} + +\def\SomeTest#1#2% + {\lefthyphenmin \plusone + \righthyphenmin \plusone + \parindent \zeropoint + \everypar \emptytoks + \dontcomplain + \hbox to 2cm {% + \vtop {% + \hsize 1pt + \hyphenationbounds#1 + #2 + \par}}} + +\startplacefigure[reference=hb:1,title={\type{one}}] + \startcombination[4*1] + {\SomeTest{0}{one}} {\type{0}} + {\SomeTest{1}{one}} {\type{1}} + {\SomeTest{2}{one}} {\type{2}} + {\SomeTest{3}{one}} {\type{3}} + \stopcombination +\stopplacefigure +\startplacefigure[reference=hb:2,title={\type{one\null two}}] + \startcombination[4*1] + {\SomeTest{0}{one\null two}} {\type{0}} + {\SomeTest{1}{one\null two}} {\type{1}} + {\SomeTest{2}{one\null two}} {\type{2}} + {\SomeTest{3}{one\null two}} {\type{3}} + \stopcombination +\stopplacefigure +\startplacefigure[reference=hb:3,title={\type{\null one\null two}}] + \startcombination[4*1] + {\SomeTest{0}{\null one\null two}} {\type{0}} + {\SomeTest{1}{\null one\null two}} {\type{1}} + {\SomeTest{2}{\null one\null two}} {\type{2}} + {\SomeTest{3}{\null one\null two}} {\type{3}} + \stopcombination +\stopplacefigure +\startplacefigure[reference=hb:4,title={\type{one\null two\null}}] + \startcombination[4*1] + {\SomeTest{0}{one\null two\null}} {\type{0}} + {\SomeTest{1}{one\null two\null}} {\type{1}} + {\SomeTest{2}{one\null two\null}} {\type{2}} + {\SomeTest{3}{one\null two\null}} {\type{3}} + \stopcombination +\stopplacefigure +\startplacefigure[reference=hb:5,title={\type{\null one\null two\null}}] + \startcombination[4*1] + {\SomeTest{0}{\null one\null two\null}} {\type{0}} + {\SomeTest{1}{\null one\null two\null}} {\type{1}} + {\SomeTest{2}{\null one\null two\null}} {\type{2}} + {\SomeTest{3}{\null one\null two\null}} {\type{3}} + \stopcombination +\stopplacefigure + % (Future versions of \LUATEX\ might provide more granularity.) In traditional \TEX\ ligature building and hyphenation are interwoven with the diff --git a/doc/context/sources/general/manuals/luatex/luatex-lua.tex b/doc/context/sources/general/manuals/luatex/luatex-lua.tex index 0960f8032..e2edcecc9 100644 --- a/doc/context/sources/general/manuals/luatex/luatex-lua.tex +++ b/doc/context/sources/general/manuals/luatex/luatex-lua.tex @@ -179,8 +179,7 @@ deal with typesetting, like \type {tex}, \type {token}, \type {node} and are \type {nil}'d). Special care is taken that \type {texio.write} and \type {texio.write_nl} function properly, so that you can at least report your actions to the log file when (and if) it eventually becomes opened (note that \TEX\ does -not even know its \type {\jobname} yet at this point). See \in {chapter} [libraries] -for more information about the \LUATEX-specific \LUA\ extension tables. +not even know its \type {\jobname} yet at this point). Everything you do in the \LUA\ initialization script will remain visible during the rest of the run, with the exception of the \TEX\ specific libraries like diff --git a/doc/context/sources/general/manuals/luatex/luatex-math.tex b/doc/context/sources/general/manuals/luatex/luatex-math.tex index c76d7ad5f..f8383e974 100644 --- a/doc/context/sources/general/manuals/luatex/luatex-math.tex +++ b/doc/context/sources/general/manuals/luatex/luatex-math.tex @@ -1091,8 +1091,6 @@ with zero being the default behaviour. \def\OneLiner#1#2% {\NC #1 -% \NC \ruledhbox{\mathsurroundmode#1\relax\hsize 100pt x$x$x} -% \NC \ruledhbox{\mathsurroundmode#1\relax\hsize 100pt x $x$ x} \NC \dontleavehmode\inframed[align=normal,offset=0pt,frame=off]{\mathsurroundmode#1\relax\hsize 100pt x$x$x} \NC \dontleavehmode\inframed[align=normal,offset=0pt,frame=off]{\mathsurroundmode#1\relax\hsize 100pt x $x$ x} \NC #2 @@ -1124,7 +1122,7 @@ with zero being the default behaviour. Method six omits the surround glue when there is (x)spacing glue present while method seven does the opposite, the glue is only applied when there is (x)space -glue present too. Anything more fance, like checking the begining or end of a +glue present too. Anything more fancy, like checking the begining or end of a paragraph (or edges of a box) would not be robust anyway. If you want that you can write a callback that runs over a list and analyzes a paragraph. Actually, in that case you could also inject glue (or set the properties of a math node) diff --git a/doc/context/sources/general/manuals/math/math-introduction.tex b/doc/context/sources/general/manuals/math/math-introduction.tex index 70e766669..c89d1d7b1 100644 --- a/doc/context/sources/general/manuals/math/math-introduction.tex +++ b/doc/context/sources/general/manuals/math/math-introduction.tex @@ -9,8 +9,16 @@ collection of wrap|-|ups. The file also serves as testcase. The content can change over time and can also serve as a trigger for discussions on the mailing list. Suggestions are welcome. +We discuss high level as well as low level commands. Some of the low level +commands (primitives) are wrapped in high level commands but you can of course +always revert to bare \TEX. + +I won't go into much detail about typesetting beautiful math, for that I refer to +the \TEX book. \footnote {The most beautiful math is not typeset by \TEX\ anyway: +just search on YouTube for \quotation {Mathematics} by Hollie McNish, the +Metropole Orkest (conducted by Jules Buckley) and Martin Pyper.} + % https://www.youtube.com/watch?v=SB8_2Yuj8Og -% youtube: Mathematics - Hollie + Metropole Orkest (conducted by Jules Buckley) \startlines Hans Hagen diff --git a/doc/context/sources/general/manuals/math/math-layout.tex b/doc/context/sources/general/manuals/math/math-layout.tex index 92ced8f22..5e84c996e 100644 --- a/doc/context/sources/general/manuals/math/math-layout.tex +++ b/doc/context/sources/general/manuals/math/math-layout.tex @@ -1,10 +1,17 @@ \startenvironment math-layout -\switchtobodyfont [modern] -\switchtobodyfont [dejavu] -\switchtobodyfont [cambria] -\switchtobodyfont[lucidaot] -\switchtobodyfont [xits] +\enabledirectives[fontgoodies.mathkerning] + +\usebodyfont [modern] +\usebodyfont [cambria] +\usebodyfont [lucidaot] +\usebodyfont [xits] +\usebodyfont [stixtwo] +\usebodyfont [dejavu] +\usebodyfont [pagella] +\usebodyfont [termes] +\usebodyfont [bonum] +\usebodyfont [schola] \setupbodyfont [pagella] diff --git a/doc/context/sources/general/manuals/math/math-spacing.tex b/doc/context/sources/general/manuals/math/math-spacing.tex index 3412a3abc..02f2c71a8 100644 --- a/doc/context/sources/general/manuals/math/math-spacing.tex +++ b/doc/context/sources/general/manuals/math/math-spacing.tex @@ -392,6 +392,276 @@ Of course better is to fix the font. \stopsection +\startsection[title=Multiline] + +Inline formulas can span lines but display math normally sits on one line unless +one uses alignment mechanisms. Take this: + +\startbuffer +\startformula + x\dorecurse{30}{ + #1x^{#1x}} = 10 +\stopformula +\stopbuffer + +\typebuffer + +\par \start \setupformula[split=no] \getbuffer \stop \par + +You can set \type {split} to \type {yes} using \type {\setupformula} and get the +following: + +\par \start \setupformula[split=yes] \getbuffer \stop \par + +Maybe nicer is to also set \type {align} to \type {flushleft}: + +\par \start \setupformula[split=yes,align=flushleft] \getbuffer \stop \par + +There is an experimental alignment mechanism available. Watch the following +examples: + +\startbuffer[demo] +before + \startformula + z + 3y = \alignhere x + \dorecurse{20}{ + #1x^{#1x}} + \stopformula +inbetween + \startformula + z + 3y \alignhere = 1 + \dorecurse{4}{ + \dorecurse{#1}{+ #1x^{##1x}} + \ifnum#1<4\breakhere\fi + } + \stopformula +after +\stopbuffer + +\typebuffer[demo] + +\startbuffer[setup] +\setupformula + [split=no] +\stopbuffer + +\typebuffer[setup] \start \getbuffer[setup,demo] \stop + +\startbuffer[setup] +\setupformula + [split=yes, + align=flushleft] +\stopbuffer + +\typebuffer[setup] \start \getbuffer[setup,demo] \stop + +\startbuffer[setup] +\setupformula + [split=yes, + align=flushleft, + hang=auto] +\stopbuffer + +\typebuffer[setup] \start \getbuffer[setup,demo] \stop + +\startbuffer[setup] +\setupformula + [split=yes, + align=flushleft, + hang=auto, + distance=1em] +\stopbuffer + +\typebuffer[setup] \start \getbuffer[setup,demo] \stop + +\startbuffer[setup] +\setupformula + [split=yes, + align=flushleft, + hang=yes, + distance=2em] +\stopbuffer + +\typebuffer[setup] \start \getbuffer[setup,demo] \stop + +\startbuffer[setup] +\setupformula + [split=yes, + align=flushleft, + hang=yes, + distance=2em, + interlinespace=1.5\lineheight] +\stopbuffer + +\typebuffer[setup] \start \getbuffer[setup,demo] \stop + +If you want to split over pages, you can say: + +\starttyping +\setupformula + [split=page, + align=middle] +\stoptyping + +but that is rather experimental (especially in combination with other +number placement related options). + +\stopsection + +\startsection[title=Scripts] + +Superscripts and subscripts are typeset in a smaller size than their nucleus. You +can influence that as follows: + +\startbuffer +\startformula +x^{2} = x^{\textstyle 2} + = x^{\scriptstyle 2} + = x^{\scriptscriptstyle 2} +\stopformula +\stopbuffer + +\typebuffer \getbuffer + +You can also use macros instead of a \type {^} and \type {_}, as in: + +\startbuffer +\startformula +x \superscript {2} = +x \superscript {\textstyle 2} = +x \superscript {\scriptstyle 2} = +x \superscript {\scriptscriptstyle 2} = +x \nosuperscript {2} +\stopformula +\stopbuffer + +\typebuffer \getbuffer + +The \type {\nosuperscript} primitive makes sure that we get the same size as the +nucleus. + +\startbuffer +\startformula +x \superscript {2} \subscript {i} = +x \nosuperscript {2} \subscript {i} = +x \superscript {2} \nosubscript {i} = +x \nosuperscript {2} \nosubscript {i} +\stopformula +\stopbuffer + +\typebuffer \getbuffer + +\stopsection + +\startsection[title=Text accents] + +You can put an accent over a character: + +\startbuffer +$\grave{x} \neq \grave{i}$\quad +$\ddot {x} \neq \ddot {i}$\quad +$\bar {x} \neq \bar {i}$\quad +$\acute{x} \neq \acute{i}$\quad +$\hat {x} \neq \hat {i}$\quad +$\check{x} \neq \check{i}$\quad +$\breve{x} \neq \breve{i}$\quad +$\dot {x} \neq \dot {i}$\quad +$\ring {x} \neq \ring {i}$\quad +$\tilde{x} \neq \tilde{i}$\quad +$\dddot{x} \neq \dddot{i}$\quad +\stopbuffer + +\typebuffer + +This comes out as: \inlinebuffer. For regular text you can better use proper composed +\UTF\ encoded characters. + +\stopsection + +\startsection[title=Directions] + +Math has its own direction control: + +\starttexdefinition unexpanded MathTest #1#2#3 + \ruledvbox \bgroup + \mathdir#1\relax + \textdir#2\relax + \pardir #3\relax + \hsize=30mm + \startformula + a^2+b^2=c^2 + \stopformula + \egroup +\stoptexdefinition + +\starttexdefinition unexpanded MathShow #1#2#3#4 + \hbox \bgroup + \infofont #1 : m=#2 t=#3 p=#4 + \egroup +\stoptexdefinition + +\startbuffer +\startcombination[nx=4,ny=2,distance=1cm] + {\MathTest{TLT}{TLT}{TLT}} {\MathShow1{TLT}{TLT}{TLT}} + {\MathTest{TLT}{TLT}{TRT}} {\MathShow2{TLT}{TLT}{TRT}} + {\MathTest{TLT}{TRT}{TLT}} {\MathShow3{TLT}{TRT}{TLT}} + {\MathTest{TLT}{TRT}{TRT}} {\MathShow4{TLT}{TRT}{TRT}} + {\MathTest{TRT}{TLT}{TLT}} {\MathShow5{TRT}{TLT}{TLT}} + {\MathTest{TRT}{TLT}{TRT}} {\MathShow6{TRT}{TLT}{TRT}} + {\MathTest{TRT}{TRT}{TLT}} {\MathShow7{TRT}{TRT}{TLT}} + {\MathTest{TRT}{TRT}{TRT}} {\MathShow8{TRT}{TRT}{TRT}} +\stopcombination +\stopbuffer + +\typebuffer + +Normally you will not control directions this way but use the proper parameters +in layout related setup commands. + +\startlinecorrection +\getbuffer +\stoplinecorrection + +\stopsection + +\startsection[title=Surround] + +The spacing around inline formulas is consistent with other +spacing but it can be enlarged. We just show a few examples: + +\startbuffer[demo] +\hsize 20em +We have +\dorecurse {8} {% + \ifcase#1\or\else and \fi + $x+#1$ and $x-#1$ and $x \times #1$ +} +\removeunwantedspaces . +\par +\stopbuffer + +\typebuffer[demo] + +\blank \start \getbuffer[demo] \stop + +\startbuffer[setup] +\setupmathematics + [textdistance=2pt plus 1pt minus 1pt] +\stopbuffer + +\typebuffer[setup] + +\blank \start \getbuffer[setup,demo] \stop + +\startbuffer[setup] +\setupmathematics + [textdistance=4pt plus 2pt minus 2pt] +\stopbuffer + +\typebuffer[setup] + +\blank \start \getbuffer[setup,demo] \stop + +\stopsection + \stopchapter \stopcomponent diff --git a/doc/context/sources/general/manuals/math/math-tricks.tex b/doc/context/sources/general/manuals/math/math-tricks.tex new file mode 100644 index 000000000..92d764b92 --- /dev/null +++ b/doc/context/sources/general/manuals/math/math-tricks.tex @@ -0,0 +1,653 @@ +\environment math-layout + +\startcomponent math-tricks + +\startchapter[title=Tricks] + +\startsection[title=Introduction] + +Math support in \CONTEXT\ is wrapped around basic \TEX\ primitives and +unfortunately not all we want is easy to configure. This is not surprising +because the original ideas behind \TEX\ are that one makes a style per book and a +one macro package \quote {we-can-do-it-all} approach is not what Don Knuth had in +mind at that time. + +So, for instance support for configurable spacing per math element, coloring of +specific (sub) elements, simple switching of whatever combination of alignments +and number placement, these all take quite a bit of code and hackery. + +Even configuring something seemingly trivial as fractions or top, bottom, left, +middle and right fences take some effort. This is because the engine uses +information from fonts to combine shapes and paste the content and ornaments to +together. + +For that reason already in \MKII\ but more extensively in \MKIV\ we did a lot of +these things in wrapper macros. When the math renderer was finalized for +\OPENTYPE\ math some extra control was added that can make these things easier. +However, because we go a bit beyond what is possible using this new functionality +these new mechanisms are not yet used in \MKIV, but they might be eventually. +Here we just show some of the (newer) low level trickery. For details about what +was already possible in pure \TEX, we refer to the ultimate references: the \TeX +book (by Donald Knuth) and \TeX\ by Topic (by Victor Eijkhout). + +\stopsection + +\startsection[title=Kerning] + +Kerning in \OPENTYPE\ math is not the same as in traditional \TEX: instead of a +single value, we have staircase kerns, that is, depending on the location (left +or right) and the vertical position, at discrete distances between depth and +height. In addition there is italic correction but that is only applied in +certain cases, one of which is the script location. + +Unfortunately not all fonts follow the same route. Some fonts have a true width +and a moderate italic correction is added to it (of at all), while other fonts +lie about the width and depend on an excessive italic correction to compensate +for that. + +\definemeasure[quarter][\dimexpr(\textwidth-3em)/4\relax] + +\def\TestKern#1% + {\scale + [width=\measure{quarter}] + {\hbox to 50pt{\hss\showboxes\switchtobodyfont[#1]$V_i^i = W_i^i$\hss}}} + +\startlinecorrection +\startcombination[nx=4,ny=2,distance=1em] + {\TestKern {modern}} {\infofont modern} + {\TestKern {cambria}} {\infofont cambria} + {\TestKern{lucidaot}} {\infofont lucida} + {\TestKern {dejavu}} {\infofont dejavu} + {\TestKern {pagella}} {\infofont pagella} + {\TestKern {termes}} {\infofont termes} + {\TestKern {bonum}} {\infofont bonum} + {\TestKern {schola}} {\infofont schola} +\stopcombination +\stoplinecorrection + +I will not discuss the details because when a font gets updated, it might look +better or worse. These fonts were loaded with the following directive set: + +\starttyping +\enabledirectives[fontgoodies.mathkerning] +\stoptyping + +An example of a fontgoodie that fixed the kerning is \type {pagella-math.lfg}. Here +is the relevant bit: + +\starttyping +local kern_200 = { bottomright = { { kern = -200 } } } +local kern_100 = { bottomright = { { kern = -100 } } } + +return { + ..... + mathematics = { + ..... + kerns = { + [0x1D449] = kern_200, -- 𝑉 + [0x1D44A] = kern_100, -- 𝑊 + }, + ..... + } +} +\stoptyping + +This fixes the real bad kerning of Pagella Math which at least in 2017 was not +(yet) fixed. When the fonts are frozen we can start makling permanent runtime +fixes like this. + +\stopsection + +\startsection[title=Primes] + +Primes are a pain in the butt. The reason for this is that they are independent +characters on the one hand but can be seen as a superscript on the other. Let's +first look at the symbols at the three sizes that are used in math. + +\startbuffer[prime] +$ + {\textstyle \char"2032} + {\scriptstyle \char"2032} + {\scriptscriptstyle\char"2032} +\quad + {\textstyle \char"FE931} + {\scriptstyle \char"FE931} + {\scriptscriptstyle\char"FE931} +\quad + {\textstyle \char"FE932} + {\scriptstyle \char"FE932} + {\scriptscriptstyle\char"FE932} +$ +\stopbuffer + +\typebuffer[prime] + +We blow up the characters a bit and get this: + +\startlinecorrection +\scale[scale=5000]{\showglyphs\inlinebuffer[prime]} +\stoplinecorrection + +\def\TestPrime#1% + {\scale + [width=\measure{quarter}] + {\ruledhbox to 65pt{% + \hss + \showglyphs + \switchtobodyfont[#1]% + \inlinebuffer[prime]% + \hss}}} + +The first set is the normal prime character scaled to the text, script and +scriptscriptsize. The second set shows the characters (at three sizes) as they +are in the font. The largest character is raised while the other two are closer +to the baseline. In some fonts the smaller sizes arenot smaller at all. The last +set is a variant of the the first set but we made them into virtual characters +with a displacement and different dimensions. Those are the ones we use as +primes. + +\startlinecorrection +\startcombination[nx=4,ny=2,distance=1em] + {\TestPrime {modern}} {\infofont modern} + {\TestPrime {cambria}} {\infofont cambria} + {\TestPrime{lucidaot}} {\infofont lucida} + {\TestPrime {dejavu}} {\infofont dejavu} + {\TestPrime {pagella}} {\infofont pagella} + {\TestPrime {termes}} {\infofont termes} + {\TestPrime {bonum}} {\infofont bonum} + {\TestPrime {schola}} {\infofont schola} +\stopcombination +\stoplinecorrection + +Next we show how primes show up in real math. The examples +explain themselves. + +\startbuffer +{\textstyle f = g} \quad +{\scriptstyle f = g} \quad +{\scriptscriptstyle f = g} +\stopbuffer + +\typebuffer + +\startlinecorrection +\scale[scale=2000]{\showglyphs$\inlinebuffer$} +\stoplinecorrection + +\startbuffer +{\textstyle f_i' = g_i'} \quad +{\scriptstyle f_i' = g_i'} \quad +{\scriptscriptstyle f_i' = g_i'} +\stopbuffer + +\typebuffer + +\startlinecorrection +\scale[scale=2000]{\showglyphs$\inlinebuffer$} +\stoplinecorrection + +\startbuffer +{\textstyle f^{\char"2032}(0) = g^{\char"2032}(0)} \quad +{\scriptstyle f^{\char"2032}(0) = g^{\char"2032}(0)} \quad +{\scriptscriptstyle f^{\char"2032}(0) = g^{\char"2032}(0)} +\stopbuffer + +\typebuffer + +\startlinecorrection +\scale[scale=2000]{\showglyphs$\inlinebuffer$} +\stoplinecorrection + +\startbuffer +{\textstyle f'(0) = g'(0)} \quad +{\scriptstyle f'(0) = g'(0)} \quad +{\scriptscriptstyle f'(0) = g'(0)} +\stopbuffer + +\typebuffer + +\startlinecorrection +\scale[scale=2000]{\showglyphs$\inlinebuffer$} +\stoplinecorrection + +\startbuffer +{\textstyle f^{\char"2032}(0) = g^{\char"2032}(0)} \quad +{\scriptstyle f^{\char"2032}(0) = g^{\char"2032}(0)} \quad +{\scriptscriptstyle f^{\char"2032}(0) = g^{\char"2032}(0)} +\stopbuffer + +\typebuffer + +\startlinecorrection +\scale[scale=2000]{\showglyphs$\inlinebuffer$} +\stoplinecorrection + +\startbuffer +{\textstyle f^{\char"2032}(0) = g^{\char"2032}(0)} \quad +{\scriptstyle f^{\char"2032}(0) = g^{\char"2032}(0)} \quad +{\scriptscriptstyle f^{\char"2032}(0) = g^{\char"2032}(0)} +\stopbuffer + +\typebuffer + +\startlinecorrection +\scale[scale=2000]{\showglyphs$\inlinebuffer$} +\stoplinecorrection + +The prime analyzer can deal with sizes, subscripts but also converts a sequence +of upright quotes into one unicode symbol. So, + +\startbuffer +f'_i \neq f''_i \neq f'''_i \neq f''''_i +\stopbuffer + +\typebuffer + +becomes: + +\startlinecorrection +\scale[scale=4000]{\showglyphs$\inlinebuffer$} +\stoplinecorrection + +\stopsection + +\startsection[title=Radicals] + +Sometimes users complain about the look of a radical symbol. This is however a matter +of design. Some fonts let the shape start more below the baseline than others. Soem go +more straight up than relatives in another font. When largers sizes are needed, some +fonts offer smaller than others. Just look at the different desings: + +\def\TestRadical#1% + {\NC + \type{#1}\blackrule[width=0pt,height=2.5ex,depth=2ex]\NC + \switchtobodyfont[#1]\scale[scale=2000]{\showglyphs$\surd $}\NC + \switchtobodyfont[#1]\scale[scale=2000]{\showglyphs$\sqrt{} $}\NC + \switchtobodyfont[#1]\scale[scale=2000]{\showglyphs$\sqrt{.}$}\NC + \switchtobodyfont[#1]\scale[scale=2000]{\showglyphs$\sqrt{x}$}\NC + \switchtobodyfont[#1]\scale[scale=2000]{\showglyphs$\surd \sqrt{} \sqrt{.} \sqrt{x}$}\NC + \NR} + +\starttabulate[|l|c|c|c|c|c|] + \NC \NC \type{\surd} \NC \type{\sqrt{}} \NC \type{\sqrt{.}} \NC \type{\sqrt{x}} \NC \NR + \TestRadical{modern} + \TestRadical{cambria} + \TestRadical{lucidaot} + \TestRadical{dejavu} + \TestRadical{pagella} + \TestRadical{termes} + \TestRadical{bonum} + \TestRadical{schola} +\stoptabulate + +The automatic scaling doesn't always work out as expected but on the average is +okay. Keep in mind that often the content is not that extreme. + +\def\TestRadical#1% + {\NC + \type{#1}\NC + \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=1.0ex,color=darkgray]}$\NC + \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=1.5ex,color=darkgray]}$\NC + \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=2.0ex,color=darkgray]}$\NC + \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=2.5ex,color=darkgray]}$\NC + \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=3.0ex,color=darkgray]}$\NC + \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=3.5ex,color=darkgray]}$\NC + \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=4.0ex,color=darkgray]}$\NC + \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=4.5ex,color=darkgray]}$\NC + \NR} + +\starttabulate[|l|c|c|c|c|c|c|c|c|] + \NC \NC 1.0ex \NC 1.5ex \NC 2.0ex \NC 2.5ex \NC 3.0ex \NC 3.5ex \NC 4.0ex \NC 4.5ex \NC \NR + \TestRadical{modern} + \TestRadical{cambria} + \TestRadical{lucidaot} + \TestRadical{dejavu} + \TestRadical{pagella} + \TestRadical{termes} + \TestRadical{bonum} + \TestRadical{schola} +\stoptabulate + +In Lucida (the version at the time of writing this) we have to correct the threshold +a bit in the goodie file: + +\starttyping +local function FixRadicalDisplayStyleVerticalGap(value,target,original) + local o = original.mathparameters.RadicalVerticalGap -- 50 + return 2 * o * target.parameters.factor +end + +return { + ..... + mathematics = { + ..... + parameters = { + RadicalDisplayStyleVerticalGap = + FixRadicalDisplayStyleVerticalGap, + }, + ..... + }, +} +\stoptyping + +\stopsection + +\startsection[title=Integrals] + +A curious exception in the math system is the integral sign. Its companions are +the summation and product signs, but integral has as extra property that it has a +slant. In \LUATEX\ there is rather advanced control over how the (optional) +scripts are positioned (which relates to italic correction) but in \CONTEXT\ we +only make limited use of that. The main reason is that we also need to support +additional features like color. Therefore integrals are handled by the extensible +mechanism. + +The size of an integral is more of less fixed but you can enlarge to your +liking. One reason for this is that you might want a consistent size across +formulas. Let's use the following setup: + +\startbuffer[setup] +\setupmathextensible + [integral] + [rightoffset=-1mu, + exact=yes, + factor=2] + +\let\int\integral +\stopbuffer + +\typebuffer[setup] + +We use the following exmaple: + +\startbuffer[demo] +\ruledhbox{$\integral f\frac{1}{2} $}\quad +\ruledhbox{$\integral[rightoffset=3mu] f\frac{1}{2} $}\quad +\ruledhbox{$\integral[exact=no] f\frac{1}{2} $}\quad +\ruledhbox{$\integral f\frac{\frac{1}{2}}{x} $}\quad +\ruledhbox{$\integral[exact=no] f\frac{\frac{1}{2}}{x} $}\quad +\ruledhbox{$\integral[factor=1] f\frac{1}{2} $}\quad +\ruledhbox{$\integral[factor=3] f\frac{\frac{1}{2}}{x} $}\quad +\ruledhbox{$\integral[factor=3] f\frac{1}{2} $}\quad +\ruledhbox{$\int f\frac{1}{2} $}% bonus +\stopbuffer + +\typebuffer[demo] + +This renders as: + +\dontleavehmode\hbox{\getbuffer[setup,demo]} + +\stopsection + +\startsection[title=Fancy fences] + +Here I only show an example of fences drawn by \METAPOST. For the implementation +you can consult the library file \type {meta-imp-mat.mkiv} in the \CONTEXT\ +distribution. + +\startbuffer[setup] +\useMPlibrary[mat] + +\setupmathstackers + [both] % vfenced] + [color=darkred, + alternative=mp] + +\setupmathstackers + [top] + [color=darkred, + alternative=mp] + +\setupmathstackers + [bottom] + [color=darkred, + alternative=mp] +\stopbuffer + +\typebuffer[setup] + +We keep the demo simple: + +\startbuffer[demo] +$ \overbracket {a+b+c+d} \quad + \underbracket {a+b+c+d} \quad + \doublebracket {a+b+c+d} \quad + \overparent {a+b+c+d} \quad + \underparent {a+b+c+d} \quad + \doubleparent {a+b+c+d} $ \blank +$ \overbrace {a+b+c+d} \quad + \underbrace {a+b+c+d} \quad + \doublebrace {a+b+c+d} \quad + \overbar {a+b+c+d} \quad + \underbar {a+b+c+d} \quad + \doublebar {a+b+c+d} $ \blank +$ \overleftarrow {a+b+c+d} \quad + \overrightarrow {a+b+c+d} \quad + \underleftarrow {a+b+c+d} \quad + \underrightarrow {a+b+c+d} $ \blank +\stopbuffer + +\typebuffer[demo] + +Or visualized: + +\start +\getbuffer[setup,demo] +\stop + +\stopsection + +\stopcomponent + +% \enabletrackers[math.makeup=boxes] + +% \startTEXpage[offset=10pt] +% $\displaystyle {{1}\normalover{2}}+x$\quad $\crampeddisplaystyle {{1}\normalover{2}}+x$\blank +% $\textstyle {{1}\normalover{2}}+x$\quad $\crampedtextstyle {{1}\normalover{2}}+x$\blank +% $\scriptstyle {{1}\normalover{2}}+x$\quad $\crampedscriptstyle {{1}\normalover{2}}+x$\blank +% $\scriptscriptstyle {{1}\normalover{2}}+x$\quad $\crampedscriptscriptstyle{{1}\normalover{2}}+x$\blank +% \stopTEXpage + +% \startTEXpage[offset=10pt] +% $e=mc^2$ +% \stopTEXpage + +% \startTEXpage[offset=10pt] +% $\sqrt{\frac{1}{2}+x}$ +% \stopTEXpage + +% \startTEXpage[offset=10pt] +% $\int^0_1{\frac{1}{2}+x}$ +% \stopTEXpage + +% \startTEXpage[offset=10pt] +% $\displaystyle\the\everydisplay\int^0_1{\frac{1}{2}+x}$ +% \stopTEXpage + +% \startbuffer +% ${}^2_2x^3_4 {}^2x_4$ +% \stopbuffer + +% % d : \Umathsubshiftdown +% % u : \Umathsupshiftup +% % s : \Umathsubsupshiftdown + +% \startTEXpage[offset=10pt] +% \starttabulate[|T||cT|cT|] +% \NC 0 \NC \mathscriptsmode 0 \inlinebuffer \NC dynamic \NC dynamic \NC \NR \TB +% \NC 1 \NC \mathscriptsmode 1 \inlinebuffer \NC d \NC u \NC \NR \TB +% \NC 2 \NC \mathscriptsmode 2 \inlinebuffer \NC s \NC u \NC \NR \TB +% \NC 3 \NC \mathscriptsmode 3 \inlinebuffer \NC s \NC u + s − d \NC \NR \TB +% \NC 4 \NC \mathscriptsmode 4 \inlinebuffer \NC d + (s − d)/2 \NC u + (s − d)/2 \NC \NR \TB +% \NC 5 \NC \mathscriptsmode 5 \inlinebuffer \NC d \NC u + s − d \NC \NR +% \stoptabulate +% \stopTEXpage + +% \startTEXpage[offset=10pt] \tt +% \starttabulate[|l|ck1|ck1|ck1|ck1|ck1|ck1|] +% \NC +% \NC \mathnolimitsmode0 $\displaystyle\int\nolimits^0_1$ +% \NC \mathnolimitsmode1 $\displaystyle\int\nolimits^0_1$ +% \NC \mathnolimitsmode2 $\displaystyle\int\nolimits^0_1$ +% \NC \mathnolimitsmode3 $\displaystyle\int\nolimits^0_1$ +% \NC \mathnolimitsmode4 $\displaystyle\int\nolimits^0_1$ +% \NC \mathnolimitsmode8000 $\displaystyle\int\nolimits^0_1$ +% \NC \NR +% \TB +% \NC \bf mode +% \NC 0 +% \NC 1 +% \NC 2 +% \NC 3 +% \NC 4 +% \NC 8000 +% \NC \NR +% \NC \bf superscript +% \NC 0 +% \NC font +% \NC 0 +% \NC 0 +% \NC +ic/2 +% \NC 0 +% \NC \NR +% \NC \bf subscript +% \NC -ic +% \NC font +% \NC 0 +% \NC -ic/2 +% \NC -ic/2 +% \NC 8000ic/1000 +% \NC \NR +% \stoptabulate +% \stopTEXpage + +{ } \bgroup \egroup \begingroup \endgroup + +\startbuffer[1] + [a:\mathstyle]\quad + \bgroup + \mathchoice + {\bf \scriptstyle (x:d :\mathstyle)} + {\bf \scriptscriptstyle (x:t :\mathstyle)} + {\bf \scriptscriptstyle (x:s :\mathstyle)} + {\bf \scriptscriptstyle (x:ss:\mathstyle)} + \egroup + \quad[b:\mathstyle]\quad + \mathchoice + {\bf \scriptstyle (y:d :\mathstyle)} + {\bf \scriptscriptstyle (y:t :\mathstyle)} + {\bf \scriptscriptstyle (y:s :\mathstyle)} + {\bf \scriptscriptstyle (y:ss:\mathstyle)} + \quad[c:\mathstyle]\quad + \bgroup + \mathchoice + {\bf \scriptstyle (z:d :\mathstyle)} + {\bf \scriptscriptstyle (z:t :\mathstyle)} + {\bf \scriptscriptstyle (z:s :\mathstyle)} + {\bf \scriptscriptstyle (z:ss:\mathstyle)} + \egroup + \quad[d:\mathstyle] +\stopbuffer + +\startbuffer[2] + [a:\mathstyle]\quad + \begingroup + \mathchoice + {\bf \scriptstyle (x:d :\mathstyle)} + {\bf \scriptscriptstyle (x:t :\mathstyle)} + {\bf \scriptscriptstyle (x:s :\mathstyle)} + {\bf \scriptscriptstyle (x:ss:\mathstyle)} + \endgroup + \quad[b:\mathstyle]\quad + \mathchoice + {\bf \scriptstyle (y:d :\mathstyle)} + {\bf \scriptscriptstyle (y:t :\mathstyle)} + {\bf \scriptscriptstyle (y:s :\mathstyle)} + {\bf \scriptscriptstyle (y:ss:\mathstyle)} + \quad[c:\mathstyle]\quad + \begingroup + \mathchoice + {\bf \scriptstyle (z:d :\mathstyle)} + {\bf \scriptscriptstyle (z:t :\mathstyle)} + {\bf \scriptscriptstyle (z:s :\mathstyle)} + {\bf \scriptscriptstyle (z:ss:\mathstyle)} + \endgroup + \quad[d:\mathstyle] +\stopbuffer + +% % \bgroup .. \egroup + +% \startTEXpage[offset=10pt] +% $\displaystyle \getbuffer[1]$ \blank +% $\textstyle \getbuffer[1]$ +% \stopTEXpage + +% % \begingroup .. \endgroup + +% \startTEXpage[offset=10pt] +% $\displaystyle \getbuffer[2]$ \blank +% $\textstyle \getbuffer[2]$ +% \stopTEXpage + + +% \startTEXpage[offset=10pt] +% $\Uleft ( x \Umiddle\| \Uright )$ +% $\Uleft height 3ex ( x \Umiddle\| \Uright height 3ex )$ +% $\Uleft axis height 3ex ( x \Umiddle\| \Uright axis height 3ex )$ +% $\Uleft axis height 3ex depth 1ex ( x \Umiddle\| \Uright axis height 3ex depth 1ex )$ +% \stopTEXpage + +% \startTEXpage[offset=10pt] +% $\Uvextensible ( \frac{1}{x}$ +% $\Uvextensible height 3ex ( \frac{1}{x}$ +% $\Uvextensible axis height 3ex ( \frac{1}{x}$ +% $\Uvextensible axis height 3ex depth 1ex ( \frac{1}{x}$ +% $\Uvextensible exact axis height 3ex depth 1ex ( \frac{1}{x}$ +% \stopTEXpage + +% \startTEXpage[offset=10pt] +% \ruledhbox{$\Uhextensible "0 "23DE$} +% \ruledhbox{$\Uhextensible width 3ex "0 "23DE$} +% \ruledhbox{$\Uhextensible middle width 3ex "0 "23DE$} +% \ruledhbox{$\Uhextensible left width 3ex "0 "23DE$} +% \ruledhbox{$\Uhextensible right width 3ex "0 "23DE$} +% \stopTEXpage + +% \startTEXpage[offset=10pt] +% \ruledhbox{$\Umathaccent "0 "0 "23DE {1+x}$} +% \ruledhbox{$\Umathaccent fixed "0 "0 "23DE {1+x}$} +% \ruledhbox{$\Umathaccent top "0 "0 "23DE {1+x}$} +% \ruledhbox{$\Umathaccent bottom "0 "0 "23DF {1+x}$} +% \ruledhbox{$\Umathaccent both "0 "0 "23DE "0 "0 "23DF {1+x}$} +% \ruledhbox{$\Umathaccent overlay "0 "0 "23DE {1+x}$} +% \ruledhbox{$\Umathaccent top "0 "0 "23DE fraction 800 {1+x}$} +% \stopTEXpage + +% \startTEXpage[offset=10pt] +% ${ {1} \Uskewed / {2} }$ +% ${ {1} \Uskewed / exact {2} }$ +% ${ {1} \Uskewed / noaxis {2} }$ +% ${ {1} \Uskewed / exact noaxis {2} }$ +% ${ {1} \Uskewedwithdelims / () {2} }$ +% ${ {1} \Uskewedwithdelims / () exact {2} }$ +% ${ {1} \Uskewedwithdelims / () noaxis {2} }$ +% ${ {1} \Uskewedwithdelims / () exact noaxis {2} }$ +% \stopTEXpage + +% \disabletrackers[math.makeup] + +% \stopchapter +% +% \stopcomponent + +% A \type {\matheqnogapstep} factor that determines the gap between formula and +% equation number. +% +% A \type {\mathdisplayskipmode} directive that controls display skips: 1 = always, +% 2 = only when not zero, 3 = never. +% +% \mathstyle +% +% \suppressmathparerror + diff --git a/doc/context/sources/general/manuals/workflows/workflows-synctex.tex b/doc/context/sources/general/manuals/workflows/workflows-synctex.tex index d275c5d48..1ede3c2e4 100644 --- a/doc/context/sources/general/manuals/workflows/workflows-synctex.tex +++ b/doc/context/sources/general/manuals/workflows/workflows-synctex.tex @@ -4,27 +4,29 @@ \startcomponent workflows-xml -\startchapter[title=Synctex] +\logo [SYNCTEX] {Sync\TeX} + +\startchapter[title=\SYNCTEX] \startsection[title=Introduction] -Some users like the synctex feature that is built in the \TEX\ engines. +Some users like the \SYNCTEX\ feature that is built in the \TEX\ engines. Personally I never use it because it doesn't work well with the kind of documents I maintain. If you have one document source, and don't shuffle around (reuse) text too much it probably works out okay but that is not our practice. Here I -will describe how you can enable a more \CONTEXT\ specific synctex support so +will describe how you can enable a more \CONTEXT\ specific \SYNCTEX\ support so that aware \PDF\ viewers can bring you back to the source. \stopsection \startsection[title=What we want] -The synctex method roughly works as follows. Internally \TEX\ constricts linked +The \SYNCTEX\ method roughly works as follows. Internally \TEX\ constricts linked lists of glyphs, kerns, glue, boxes, rules etc. These elements are called nodes. Some nodes carry information about the file and line where they were created. In the backend this information gets somehow translated in a (sort of) verbose tree that describes the makeup in terms of boxes, glue and kerns. From that -information the synctex parser library, hooked into a pdf viewer, can go back +information the \SYNCTEX\ parser library, hooked into a \PDF\ viewer, can go back from a position on the screen to a line in a file. One would expect this to be a relative simple rectangle based model, but as far as I can see it's way more complex than that. There are some comments that \CONTEXT\ is not supported well @@ -36,7 +38,7 @@ mechanism geared for a macro package like \LATEX. Because we have a couple of users who need to edit complex sets of documents, coded in \TEX\ or \XML, I decided to come up with a variant that doesn't use the -synctex machinery but manipulates the few synctex fields directly \footnote {This +\SYNCTEX\ machinery but manipulates the few \SYNCTEX\ fields directly \footnote {This is something that in my opinion should have been possible right from the start but it's too late now to change the system and it would not be used beyond \CONTEXT\ anyway.} and eventually outputs a straightforward file for the editor. @@ -58,14 +60,14 @@ editor} are the following: \startitem Users should not be able to reach environments (styles) and other files loaded from the (normally read|-|only) \TEX\ tree, like modules. We don't - want accidental changed in such files. + want accidental changes in such files. \stopitem \startitem We not only have \TEX\ files but also \XML\ files and these can normally - flushed in rather arbitrary ways. Although the concept of lines is sort of + flush in rather arbitrary ways. Although the concept of lines is sort of lost in such a file, there is still a relation between lines and the snippets - that make of the content of an \XML\ node. + that make out the content of an \XML\ node. \stopitem \startitem @@ -85,12 +87,12 @@ editor} are the following: It is unavoidable that we get more run time but I assume that for the average user that is no big deal. It pays off when you have a workflow when a book (or even a chapter in a book) is generated from hundreds of small \XML\ files. There is no -overhead when synctex is not used. +overhead when \SYNCTEX\ is not used. -In \CONTEXT\ we don't use the built|-|in synctex features, that is: we let +In \CONTEXT\ we don't use the built|-|in \SYNCTEX\ features, that is: we let filename and line numbers be set but often these are overloaded explicitly. The output file is not compressed and constructed by \CONTEXT. There is no benefit in -compression and the files are probably smaller than default synctex anyway. +compression and the files are probably smaller than default \SYNCTEX\ anyway. \stopsection @@ -109,7 +111,13 @@ speed up processing when needed. This command can also be given in an environmen (style). On the command line you can say \starttyping -context --synctex=context somefile.tex +context --synctex somefile.tex +\stoptyping + +A third method is to put this at the top of your file: + +\starttyping +% synctex=yes \stoptyping Often an \XML\ files is very structured and although probably the main body of @@ -117,7 +125,7 @@ text is flushed as a stream, specific elements can be flushed out of order. In educational documents flushing for instance answers to exercises can happen out of order. In that case we still need to make sure that we go to the right spot in the file. It will never be 100\% perfect but it's better than nothing. The -above command will also enable \XML support. +above command will also enable \XML\ support. If you don't want a file to be accessed, you can block it: @@ -168,7 +176,7 @@ Don't turn on this feature when you don't need it. This is one of those mechanis that hits performance badly. Depending on needs the functionality can be improved and|/|or extended. Of course -you can always use the traditional synctex method but don't expect it to behave +you can always use the traditional \SYNCTEX\ method but don't expect it to behave as described here. \stopsection |