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