Using the margin for two purposes
Dear All, I would like to use the margin for two different purposes: For brief notes, using \inmargin, and to mark entire paragraphs sections of the text with vertical lines. So, I’d like to be able to something like this \starttext \startsquigglyline \inmargin{read \\ this \\ first} \input{knuth} \stopsquigglyline \startthinline \inmargin{read \\ this \\ next} \input{tufte} \stopthinline \stoptext I know I could use frames to accomplish the vertical features within in the text area, but I’d prefer to use the margin so that framing paragraphs doesn’t indent the paragraphs compared to the unframed portions. But I also want to have the \inmargin notes to be lined up properly. So it looks like I would need to divide the margin into two horizontally separate regions. On left pages, the left region would be used for the \inmargin notes, and the (very thin) right region would be used for the vertical features (squigglyline and thinline). For right pages the other way around. Of course I’d also like the vertical features to extend across pages, if needed. Like so: Left Page Right Page read ( Knuth Tufte | read this ) Knuth Tufte | this first ( Knuth Tufte | next ) Knuth Tufte | ( Knuth Tufte | Is there a mechanism in place for that? Thanks for any hints! Matthias
On 2014-05-17 20:12, Matthias Weber wrote:
Dear All,
I would like to use the margin for two different purposes: For brief notes, using \inmargin, and to mark entire paragraphs sections of the text with vertical lines.
So, I’d like to be able to something like this
\starttext
\startsquigglyline \inmargin{read \\ this \\ first} \input{knuth} \stopsquigglyline
\startthinline \inmargin{read \\ this \\ next} \input{tufte} \stopthinline
\stoptext
I know I could use frames to accomplish the vertical features within in the text area, but I’d prefer to use the margin so that framing paragraphs doesn’t indent the paragraphs compared to the unframed portions. But I also want to have the \inmargin notes to be lined up properly. So it looks like I would need to divide the margin into two horizontally separate regions. On left pages, the left region would be used for the \inmargin notes, and the (very thin) right region would be used for the vertical features (squigglyline and thinline). For right pages the other way around. Of course I’d also like the vertical features to extend across pages, if needed. Like so:
Left Page Right Page
read ( Knuth Tufte | read this ) Knuth Tufte | this first ( Knuth Tufte | next ) Knuth Tufte | ( Knuth Tufte |
Is there a mechanism in place for that? Thanks for any hints!
Matthias
You want margin rules. The wiki has a place-holder entry for \setupmarginrules, but the ConTeXt reference manual has a couple of pages that should provide a good start. -- Rik
Thanks Rik,
that is very helpful. Now I am having some difficulties with coordinating the \inmargins with the marginrules.
In the example below, I notice the oddity that \startmarginrule[2] is closer to the text than \startmarginrule[1]
or \startmarginrule[3], which are at equal distance. I can live with that.
There are only three things I’d like to improve:
i) I’d like to put my default \inmargin arguments into the setup, but I can’t figure out whether to use \setupinmargin
or \setupinmargindata, and where to put the arguments.
ii) Ideally I’d like to use a description to be able to write \startgreenline … \stopgreenline, and I have tried this with
\setupdescription, but failed.
iii) Dream: Instead of solid margin rules I would love to have other options, like squiggly lines, dashed, dotted.
Thanks!
Matthias
\setupmarginrule[rulethickness=.1pt] % works
\setupmargindata[][align=middle,width=2cm] %???
\definedescription[greenline] % ???
[before={\setupmarginrule[rulecolor=green]
\indenting[no]
\startmarginrule[2]},
after={\stopmarginrule}
]
\starttext
\inmargin[method=first][frame=on,corner=round] {Read\\this\\first}
\setupmarginrule[rulecolor=red]
\indenting[no]
\startmarginrule[1]
\input{knuth}
\stopmarginrule
\inmargin[method=first][frame=on,corner=round,align=middle,width=2cm,offset=3pt] {Read\\this\\second}
\setupmarginrule[rulecolor=green]
\indenting[no]
\startmarginrule[2]
\input{tufte}
\stopmarginrule
\inmargin[][frame=on,corner=round,align=middle,width=2cm] {Read\\this\\third}
\setupmarginrule[rulecolor=blue]
\indenting[no]
\startmarginrule[3]
\input{knuth}
\stopmarginrule
\inmargin[][frame=on,corner=round,align=middle,width=2cm] {Read\\this\\fourth}
\setupmarginrule[rulecolor=black]
\indenting[no]
\startmarginrule[4]
\input{knuth}
\stopmarginrule
\startgreenline
\input{tufte}
\stopgreenline
\stoptext
On May 17, 2014, at 8:21 PM, Rik Kabel
On 2014-05-17 20:12, Matthias Weber wrote:
Dear All,
I would like to use the margin for two different purposes: For brief notes, using \inmargin, and to mark entire paragraphs sections of the text with vertical lines.
So, I’d like to be able to something like this
\starttext
\startsquigglyline \inmargin{read \\ this \\ first} \input{knuth} \stopsquigglyline
\startthinline \inmargin{read \\ this \\ next} \input{tufte} \stopthinline
\stoptext
I know I could use frames to accomplish the vertical features within in the text area, but I’d prefer to use the margin so that framing paragraphs doesn’t indent the paragraphs compared to the unframed portions. But I also want to have the \inmargin notes to be lined up properly. So it looks like I would need to divide the margin into two horizontally separate regions. On left pages, the left region would be used for the \inmargin notes, and the (very thin) right region would be used for the vertical features (squigglyline and thinline). For right pages the other way around. Of course I’d also like the vertical features to extend across pages, if needed. Like so:
Left Page Right Page
read ( Knuth Tufte | read this ) Knuth Tufte | this first ( Knuth Tufte | next ) Knuth Tufte | ( Knuth Tufte |
Is there a mechanism in place for that? Thanks for any hints!
Matthias
You want margin rules. The wiki has a place-holder entry for \setupmarginrules, but the ConTeXt reference manual has a couple of pages that should provide a good start.
-- Rik ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On Sun, 18 May 2014, Matthias Weber wrote:
iii) Dream: Instead of solid margin rules I would love to have other options, like squiggly lines, dashed, dotted.
I don't have time to post a complete working example, but the normal way to achieve such features is to textbackground and let Metapost take care of the drawing. See the metafun manual for examples. Also see this answer at tex.sx http://tex.stackexchange.com/a/125486/323 for some implementation ideas. If you just need margin rules, you can also use background which are slightly simpler (less powerful but easier to work with) than textbackgrounds. Aditya
Thanks Aditya,
my metapost skills will probably not suffice to start this from scratch, but your hints made me dig around in the sources a little,
and in mp-apos.mpiv I found anch_sidebars_draw which not only draws the straight marginrules but also dotted ones, to
be invoked with \startmarginrule[2,alternative=1].
This confirms my suspicion that Hans has a time machine that allows him to implement features so that they are miraculously already available when requested.
I then tried to play around with this function a little, e.g. changing
dashed (withdots scaled (linewidth*2))
to
dashed evenly
but, to my embarrassment, it didn’t have any effect. Do I need to do something else besides saving the modified file to
have it take effect?
Thanks,
Matthias
On May 18, 2014, at 10:19 AM, Aditya Mahajan
On Sun, 18 May 2014, Matthias Weber wrote:
iii) Dream: Instead of solid margin rules I would love to have other options, like squiggly lines, dashed, dotted.
I don't have time to post a complete working example, but the normal way to achieve such features is to textbackground and let Metapost take care of the drawing. See the metafun manual for examples.
Also see this answer at tex.sx http://tex.stackexchange.com/a/125486/323 for some implementation ideas.
If you just need margin rules, you can also use background which are slightly simpler (less powerful but easier to work with) than textbackgrounds.
Aditya ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On 2014-05-18 09:50, Matthias Weber wrote:
Thanks Rik,
that is very helpful. Now I am having some difficulties with coordinating the \inmargins with the marginrules.
In the example below, I notice the oddity that \startmarginrule[2] is closer to the text than \startmarginrule[1] or \startmarginrule[3], which are at equal distance. I can live with that.
There are only three things I'd like to improve:
i) I'd like to put my default \inmargin arguments into the setup, but I can't figure out whether to use \setupinmargin or \setupinmargindata, and where to put the arguments.
ii) Ideally I'd like to use a description to be able to write \startgreenline ... \stopgreenline, and I have tried this with \setupdescription, but failed.
iii) Dream: Instead of solid margin rules I would love to have other options, like squiggly lines, dashed, dotted.
Thanks!
Matthias
\setupmarginrule[rulethickness=.1pt] % works
\setupmargindata[][align=middle,width=2cm] %???
\definedescription[greenline] % ??? [before={\setupmarginrule[rulecolor=green] \indenting[no] \startmarginrule[2]}, after={\stopmarginrule} ]
\starttext
\inmargin[method=first][frame=on,corner=round] {Read\\this\\first} \setupmarginrule[rulecolor=red] \indenting[no] \startmarginrule[1] \input{knuth} \stopmarginrule
\inmargin[method=first][frame=on,corner=round,align=middle,width=2cm,offset=3pt] {Read\\this\\second} \setupmarginrule[rulecolor=green] \indenting[no] \startmarginrule[2] \input{tufte} \stopmarginrule
\inmargin[][frame=on,corner=round,align=middle,width=2cm] {Read\\this\\third} \setupmarginrule[rulecolor=blue] \indenting[no] \startmarginrule[3] \input{knuth} \stopmarginrule
\inmargin[][frame=on,corner=round,align=middle,width=2cm] {Read\\this\\fourth} \setupmarginrule[rulecolor=black] \indenting[no] \startmarginrule[4] \input{knuth} \stopmarginrule
\startgreenline \input{tufte} \stopgreenline
\stoptext
I have been playing with this a bit. I think that the following does what you want as far as setting up the margin text and description. I am no help on the mp stuff that you will need for curly or other-dotted rules. As you probably saw, neither \setupmargindata nor \setupmarginframed are in the wiki. The list archive has some hints, but the source code, if you ignore a couple of misleading comments, suggested what I got to work. The problem you will run into with the description as you want to use it comes when you have multiple paragraphs. Without a start/stop mechanism, there is no way to mark the paragraphs to include within the scope of the line. As long as you are willing to enclose multiple paragraphs in braces (and provide a null description as I do here) you will be fine, but at that point you may as well use the start/stop. There is still a problem with the margin rule extending through the blank line that results from the implied \par at the end of the description block (and any explicit \par). It looks ugly and isn't matched by the behavior of the rule in the start/stop text. Perhaps someone else can find a way around it. Some of this is probably unnecessary for what you want; for example, instead of using optional arguments you may prefer to hardcode the choice of rule # and color. If you want to always use the same color with the same rule #, you can simplify in other ways. I did use MKVI syntax, simply because I have been trying to use it consistently in all my current work. It should be easily translated back to earlier syntax. % macros=mkvi \setupmarginrules[rulethickness=2pt,alternative=1] \setupmargindata [left] [location=left, style=\bfxx] \setupmarginframed[left] [frame=on, framecolor=darkgray, corner=round, offset=3pt, width=2cm, align=middle] \starttexdefinition startMtext \bgroup \dotripleempty\dostartMtext \stoptexdefinition \starttexdefinition dostartMtext [#RULE][#COLOR][#ORDER] \doifemptyelse{#RULE} {\def\Rule{2}}% default rule {\def\Rule{#RULE}} \doifemptyelse{#COLOR} {\def\Color{green}}% default color {\def\Color{#COLOR}} \ifthirdargument \inleft{Read\\this\\#ORDER} \fi \setupmarginrule[\Rule][rulecolor=\Color] \startmarginrule[\Rule] \stoptexdefinition \starttexdefinition stopMtext \stopmarginrule \egroup \stoptexdefinition \definedescription[greenline] [before={\setupmarginrules[rulecolor=green, alternative=0, rulethickness=0.5pt] \indenting[no] \startmarginrule[2]}, after={\stopmarginrule}] \starttext \startMtext [1][][first] \input knuth \stopMtext \startMtext [2][green][second] \input tufte \stopMtext \blank \startMtext [3][blue][third] \input tufte \stopMtext \startMtext [4][black][fourth] \input knuth \stopMtext \input knuth Just a few lines of text before the marked text. \startMtext[][red] \input tufte \stopMtext And a few lines of text after the marked text. \input knuth \blank \greenline \input knuth \blank \greenline{} {Some text and tufte: \input tufte Some more text.} \input tufte \startMtext [][magenta][last] \input tufte \stopMtext \stoptext
Thanks again, Rik,
this works like a charm, with one exception: No matter what I try, the marginrule appears always in the left margin.
Is there a way to change this?
Matthias
On May 18, 2014, at 11:42 PM, Rik
I have been playing with this a bit. I think that the following does what you want as far as setting up the margin text and description. I am no help on the mp stuff that you will need for curly or other-dotted rules.
As you probably saw, neither \setupmargindata nor \setupmarginframed are in the wiki. The list archive has some hints, but the source code, if you ignore a couple of misleading comments, suggested what I got to work.
The problem you will run into with the description as you want to use it comes when you have multiple paragraphs. Without a start/stop mechanism, there is no way to mark the paragraphs to include within the scope of the line. As long as you are willing to enclose multiple paragraphs in braces (and provide a null description as I do here) you will be fine, but at that point you may as well use the start/stop.
There is still a problem with the margin rule extending through the blank line that results from the implied \par at the end of the description block (and any explicit \par). It looks ugly and isn't matched by the behavior of the rule in the start/stop text. Perhaps someone else can find a way around it.
Some of this is probably unnecessary for what you want; for example, instead of using optional arguments you may prefer to hardcode the choice of rule # and color. If you want to always use the same color with the same rule #, you can simplify in other ways.
I did use MKVI syntax, simply because I have been trying to use it consistently in all my current work. It should be easily translated back to earlier syntax.
% macros=mkvi \setupmarginrules[rulethickness=2pt,alternative=1]
\setupmargindata [left] [location=left, style=\bfxx] \setupmarginframed[left] [frame=on, framecolor=darkgray, corner=round, offset=3pt, width=2cm, align=middle]
\starttexdefinition startMtext \bgroup \dotripleempty\dostartMtext \stoptexdefinition \starttexdefinition dostartMtext [#RULE][#COLOR][#ORDER] \doifemptyelse{#RULE} {\def\Rule{2}}% default rule {\def\Rule{#RULE}} \doifemptyelse{#COLOR} {\def\Color{green}}% default color {\def\Color{#COLOR}} \ifthirdargument \inleft{Read\\this\\#ORDER} \fi \setupmarginrule[\Rule][rulecolor=\Color] \startmarginrule[\Rule] \stoptexdefinition \starttexdefinition stopMtext \stopmarginrule \egroup \stoptexdefinition
\definedescription[greenline] [before={\setupmarginrules[rulecolor=green, alternative=0, rulethickness=0.5pt] \indenting[no] \startmarginrule[2]}, after={\stopmarginrule}]
\starttext
\startMtext [1][][first] \input knuth \stopMtext
\startMtext [2][green][second] \input tufte \stopMtext
\blank
\startMtext [3][blue][third] \input tufte \stopMtext
\startMtext [4][black][fourth] \input knuth \stopMtext
\input knuth Just a few lines of text before the marked text. \startMtext[][red] \input tufte \stopMtext And a few lines of text after the marked text. \input knuth
\blank
\greenline \input knuth
\blank
\greenline{} {Some text and tufte: \input tufte
Some more text.}
\input tufte
\startMtext [][magenta][last] \input tufte \stopMtext
\stoptext
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On 2014-05-19 12:41, Matthias Weber wrote:
Thanks again, Rik,
this works like a charm, with one exception: No matter what I try, the marginrule appears always in the left margin. Is there a way to change this?
Matthias Looking through the code in anch-bar.mkiv, there is nothing that I can see that supports placing marginrules, or the sidebars on which they are built, into the right margin. It looks like a job for Hans.
-- Rik Kabel
On 5/19/2014 9:59 PM, Rik Kabel wrote:
On 2014-05-19 12:41, Matthias Weber wrote:
Thanks again, Rik,
this works like a charm, with one exception: No matter what I try, the marginrule appears always in the left margin. Is there a way to change this?
Matthias Looking through the code in anch-bar.mkiv, there is nothing that I can see that supports placing marginrules, or the sidebars on which they are built, into the right margin. It looks like a job for Hans.
Hm, so you didn't experiment ... \starttext \definesidebar[whow][rulecolor=green,distance=0pt] \definesidebar[oeps][rulecolor=blue,distance=-\dimexpr\textwidth+2mm] \input tufte \par \startsidebar \input tufte \par \input tufte \par \startsidebar[whow] \input tufte \par \input tufte \par \input tufte \stopsidebar \par \input tufte \par \input tufte \stopsidebar \par \input tufte \par \input tufte \par \startsidebar[oeps] \input tufte \par \input tufte \par \input tufte \par \input tufte \par \input tufte \stopsidebar \par \input tufte \par \input tufte \par \startsidebar \input tufte \input tufte \input tufte \input tufte \input tufte \stopsidebar \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Thanks Hans,
while I did experiment I had no chance at divining the correct dimension distance=-\dimexpr\textwidth+2mm below.
So, with that, my bare bones marginbar in the right margin could look like the one in the file below. Where do I squeeze in the alternative=1
option to get dotted lines? When I put it into \definesidebar, the sidebar disappears, and when I write \startsidebar[oeps,alternative=1]
it reverts to the default left sidebar (albeit dotted).
Matthias
\setupmargindata [left]
[location=right,
style=\bfxx]
\setupmarginframed[left]
[frame=on,
framecolor=darkgray,
corner=round,
offset=3pt,
width=2cm,
align=middle]
\definesidebar[oeps][rulecolor=blue,distance=-\dimexpr\textwidth+2mm,rulethickness=.1pt]
\starttexdefinition startRightbar
\bgroup
\startsidebar[oeps]
\stoptexdefinition
\starttexdefinition stopRightbar
\stopsidebar
\egroup
\stoptexdefinition
\starttext
\input knuth
Just a few lines of text before the marked text.
\inmargin{Don’t\\read\\me\\again}
\startRightbar
\input tufte
\stopRightbar
And a few lines of text after the marked text.
\stoptext
On May 19, 2014, at 5:36 PM, Hans Hagen
On 5/19/2014 9:59 PM, Rik Kabel wrote:
On 2014-05-19 12:41, Matthias Weber wrote:
Thanks again, Rik,
this works like a charm, with one exception: No matter what I try, the marginrule appears always in the left margin. Is there a way to change this?
Matthias Looking through the code in anch-bar.mkiv, there is nothing that I can see that supports placing marginrules, or the sidebars on which they are built, into the right margin. It looks like a job for Hans.
Hm, so you didn't experiment ...
\starttext
\definesidebar[whow][rulecolor=green,distance=0pt] \definesidebar[oeps][rulecolor=blue,distance=-\dimexpr\textwidth+2mm]
\input tufte \par \startsidebar \input tufte \par \input tufte \par \startsidebar[whow] \input tufte \par \input tufte \par \input tufte \stopsidebar \par \input tufte \par \input tufte \stopsidebar \par \input tufte \par \input tufte \par \startsidebar[oeps] \input tufte \par \input tufte \par \input tufte \par \input tufte \par \input tufte \stopsidebar \par \input tufte \par \input tufte \par \startsidebar \input tufte \input tufte \input tufte \input tufte \input tufte \stopsidebar
\stoptext
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On 2014-05-19 19:24, Matthias Weber wrote:
Thanks Hans,
while I did experiment I had no chance at divining the correct dimension distance=-\dimexpr\textwidth+2mm below.
So, with that, my bare bones marginbar in the right margin could look like the one in the file below. Where do I squeeze in the alternative=1 option to get dotted lines? When I put it into \definesidebar, the sidebar disappears, and when I write \startsidebar[oeps,alternative=1] it reverts to the default left sidebar (albeit dotted).
Matthias
Matthias, You can use distance= in \setupmarginrules to achieve the result you want. All of the other keys work with it. The sidebar commands, if not deprecated, are not described in the wiki or in the reference manual or the command arguments manual, and have not been discussed on the list for the last six years. -- Rik
Hi Rik,
thanks again. Now I feel doubly stupid: First for not putting the distance into \setupmarginrules, and second not realizing
that the disappearing dotted margin is due to my rule thickness=.1pt.
Anyway, both approaches work now. When I get a free weekend I will head into metapost and see whether I can get my squiggles
and zigzags.
Thanks to everybody for the help!
Matthias
On May 19, 2014, at 7:50 PM, Rik
Matthias,
You can use distance= in \setupmarginrules to achieve the result you want. All of the other keys work with it. The sidebar commands, if not deprecated, are not described in the wiki or in the reference manual or the command arguments manual, and have not been discussed on the list for the last six years.
-- Rik ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
participants (5)
-
Aditya Mahajan
-
Hans Hagen
-
Matthias Weber
-
Rik
-
Rik Kabel