* Placing margin notes on the left using Lua
@ 2015-05-08 9:35 Hannes Riebl
2015-05-08 10:17 ` Wolfgang Schuster
0 siblings, 1 reply; 8+ messages in thread
From: Hannes Riebl @ 2015-05-08 9:35 UTC (permalink / raw)
To: ntg-context
Dear ConTeXt users,
I am typesetting a critical edition with margin notes. To place these, I
am using the Lua code below. It is based on the code from the LuaTeX
wiki (cf.
http://wiki.luatex.org/index.php/Post_linebreak_filter#Margin_notes) and
has the restrictions mentioned on this wiki page. For example, placing
notes on the left of the text is not possible. Now, my questions are:
(1) How can I extend the code to place notes on the left of the text? I
tried node.insert_before(line.list, line.list, glyph) but it did not
work out.
(2) How do I use the callback within the output routine to distinguish
odd and even pages?
Thank you very much for any hints or help!
Best regards
Hannes Riebl
make_notes = function(head)
for line in node.traverse_id(node.id("hlist"), head) do
...
local glyph = node.new("glyph")
glyph.font = font.current()
glyph.lang = tex.language
glyph.char = 97
node.insert_after(line.list, node.tail(line.list), glyph)
...
end
return head
end
nodes.tasks.appendaction("finalizers", "after", "make_notes")
--
Hannes Riebl
Abteilung Forschung & Entwicklung
Georg-August-Universität Göttingen
Niedersächsische Staats- und Universitätsbibliothek Göttingen
D-37070 Göttingen
Papendiek 14 (Historisches Gebäude, Raum 2.409)
hriebl@sub.uni-goettingen.de
http://www.sub.uni-goettingen.de
http://www.rdd.sub.uni-goettingen.de
http://dhd-blog.org
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Placing margin notes on the left using Lua
2015-05-08 9:35 Placing margin notes on the left using Lua Hannes Riebl
@ 2015-05-08 10:17 ` Wolfgang Schuster
2015-05-08 10:36 ` Hannes Riebl
0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Schuster @ 2015-05-08 10:17 UTC (permalink / raw)
To: mailing list for ConTeXt users
> Am 08.05.2015 um 11:35 schrieb Hannes Riebl <hriebl@sub.uni-goettingen.de>:
>
> Dear ConTeXt users,
>
> I am typesetting a critical edition with margin notes. To place these, I am using the Lua code below. It is based on the code from the LuaTeX wiki (cf. http://wiki.luatex.org/index.php/Post_linebreak_filter#Margin_notes) and has the restrictions mentioned on this wiki page. For example, placing notes on the left of the text is not possible.
Why don’t you use ConTeXt’s \margindata command to place your margin texts?
\setuppagenumbering[alternative=doublesided]
\starttext
\dorecurse{20}
{\margindata[inouter]{Knuth}
%\margindata[inleft]{Knuth}
\input knuth\par}
\stoptext
Wolfgang
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Placing margin notes on the left using Lua
2015-05-08 10:17 ` Wolfgang Schuster
@ 2015-05-08 10:36 ` Hannes Riebl
2015-05-08 10:41 ` Wolfgang Schuster
0 siblings, 1 reply; 8+ messages in thread
From: Hannes Riebl @ 2015-05-08 10:36 UTC (permalink / raw)
To: ntg-context
On 05/08/2015 12:17 PM, Wolfgang Schuster wrote:
> Why don’t you use ConTeXt’s \margindata command to place your margin texts?
Dear Wolfgang,
thank you for writing back! I cannot use \margindata because it creates
overlapping notes. Instead, I use Lua to concatenate the notes in one
line and print them side by side. Moreover, some notes are only relevant
if they refer to a piece of text that spans multiple lines. Using Lua, I
can drop the irrelevant notes. However, I would be very happy with a
solution that uses \margindata!
Best regards
Hannes Riebl
--
Hannes Riebl
Abteilung Forschung & Entwicklung
Georg-August-Universität Göttingen
Niedersächsische Staats- und Universitätsbibliothek Göttingen
D-37070 Göttingen
Papendiek 14 (Historisches Gebäude, Raum 2.409)
hriebl@sub.uni-goettingen.de
http://www.sub.uni-goettingen.de
http://www.rdd.sub.uni-goettingen.de
http://dhd-blog.org
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Placing margin notes on the left using Lua
2015-05-08 10:36 ` Hannes Riebl
@ 2015-05-08 10:41 ` Wolfgang Schuster
2015-05-08 11:14 ` Hannes Riebl
0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Schuster @ 2015-05-08 10:41 UTC (permalink / raw)
To: mailing list for ConTeXt users
> Am 08.05.2015 um 12:36 schrieb Hannes Riebl <hriebl@sub.uni-goettingen.de>:
>
> On 05/08/2015 12:17 PM, Wolfgang Schuster wrote:
>
>> Why don’t you use ConTeXt’s \margindata command to place your margin texts?
>
>
> Dear Wolfgang,
>
> thank you for writing back! I cannot use \margindata because it creates overlapping notes. Instead, I use Lua to concatenate the notes in one line and print them side by side. Moreover, some notes are only relevant if they refer to a piece of text that spans multiple lines. Using Lua, I can drop the irrelevant notes. However, I would be very happy with a solution that uses \margindata!
You can use the “stack=yes” setting for \margindata to avoid overlapping texts.
Wolfgang
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Placing margin notes on the left using Lua
2015-05-08 10:41 ` Wolfgang Schuster
@ 2015-05-08 11:14 ` Hannes Riebl
2015-05-20 15:14 ` Hannes Riebl
0 siblings, 1 reply; 8+ messages in thread
From: Hannes Riebl @ 2015-05-08 11:14 UTC (permalink / raw)
To: ntg-context
On 05/08/2015 12:41 PM, Wolfgang Schuster wrote:
> You can use the “stack=yes” setting for \margindata to avoid overlapping texts.
That's good! Is there an option to use spaces instead of new lines
between the notes? And how about dropping irrelevant notes? Just to
provide some more information: We use margin notes to mark text
omissions. However, these notes should only appear for omissions that
span multiple lines. Any ideas how to cope with this requirement?
Best regards
Hannes Riebl
--
Hannes Riebl
Abteilung Forschung & Entwicklung
Georg-August-Universität Göttingen
Niedersächsische Staats- und Universitätsbibliothek Göttingen
D-37070 Göttingen
Papendiek 14 (Historisches Gebäude, Raum 2.409)
hriebl@sub.uni-goettingen.de
http://www.sub.uni-goettingen.de
http://www.rdd.sub.uni-goettingen.de
http://dhd-blog.org
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Placing margin notes on the left using Lua
2015-05-08 11:14 ` Hannes Riebl
@ 2015-05-20 15:14 ` Hannes Riebl
2015-05-20 15:21 ` luigi scarso
0 siblings, 1 reply; 8+ messages in thread
From: Hannes Riebl @ 2015-05-20 15:14 UTC (permalink / raw)
To: ntg-context
On 05/08/2015 01:14 PM, Hannes Riebl wrote:
> That's good! Is there an option to use spaces instead of new lines
> between the notes? And how about dropping irrelevant notes? Just to
> provide some more information: We use margin notes to mark text
> omissions. However, these notes should only appear for omissions that
> span multiple lines. Any ideas how to cope with this requirement?
>
> Best regards
> Hannes Riebl
I have finally been able to solve this problem with the following
workflow: (1) Compile the document using Lua to genenate two text files:
one that contains the lines and line breaks and another one that
contains the corresponding margin notes. (2) Use Perl to add \margindata
in the right places of the ConTeXt source code. (3) Compile the document
again. It's hacky but it works. Anyways, guess it's been a very unusual
requirement...
Best regards
Hannes Riebl
--
Hannes Riebl
Abteilung Forschung & Entwicklung
Georg-August-Universität Göttingen
Niedersächsische Staats- und Universitätsbibliothek Göttingen
D-37070 Göttingen
Papendiek 14 (Historisches Gebäude, Raum 2.409)
hriebl@sub.uni-goettingen.de
http://www.sub.uni-goettingen.de
http://www.rdd.sub.uni-goettingen.de
http://dhd-blog.org
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Placing margin notes on the left using Lua
2015-05-20 15:14 ` Hannes Riebl
@ 2015-05-20 15:21 ` luigi scarso
2015-05-20 16:44 ` Hannes Riebl
0 siblings, 1 reply; 8+ messages in thread
From: luigi scarso @ 2015-05-20 15:21 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 1069 bytes --]
On Wed, May 20, 2015 at 5:14 PM, Hannes Riebl <hriebl@sub.uni-goettingen.de>
wrote:
> On 05/08/2015 01:14 PM, Hannes Riebl wrote:
>
>> That's good! Is there an option to use spaces instead of new lines
>> between the notes? And how about dropping irrelevant notes? Just to
>> provide some more information: We use margin notes to mark text
>> omissions. However, these notes should only appear for omissions that
>> span multiple lines. Any ideas how to cope with this requirement?
>>
>> Best regards
>> Hannes Riebl
>>
>
> I have finally been able to solve this problem with the following
> workflow: (1) Compile the document using Lua to genenate two text files:
> one that contains the lines and line breaks and another one that contains
> the corresponding margin notes. (2) Use Perl to add \margindata in the
> right places of the ConTeXt source code. (3) Compile the document again.
> It's hacky but it works. Anyways, guess it's been a very unusual
> requirement...
>
>
> Best regards
> Hannes Riebl
>
> Is it possible to have and see an example ?
--
luigi
[-- Attachment #1.2: Type: text/html, Size: 1678 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Placing margin notes on the left using Lua
2015-05-20 15:21 ` luigi scarso
@ 2015-05-20 16:44 ` Hannes Riebl
0 siblings, 0 replies; 8+ messages in thread
From: Hannes Riebl @ 2015-05-20 16:44 UTC (permalink / raw)
To: ntg-context
On 05/20/2015 05:21 PM, luigi scarso wrote:
> Is it possible to have and see an example ?
Of course! Not sure if this mailing list allows attachments, so I
uploaded my code:
https://www.dropbox.com/s/bp1s9fubha4ml0m/notes.zip?dl=0
Just extract the archive, run make.pl and have a look at output.pdf.
Remember that we use margin notes to mark text omissions. Note how the
margin note for the omission that spans multiple lines is different from
the margin note for the omission that does not. While the code is not
perfect, it works well enough for me.
Best regards
Hannes Riebl
--
Hannes Riebl
Abteilung Forschung & Entwicklung
Georg-August-Universität Göttingen
Niedersächsische Staats- und Universitätsbibliothek Göttingen
D-37070 Göttingen
Papendiek 14 (Historisches Gebäude, Raum 2.409)
hriebl@sub.uni-goettingen.de
http://www.sub.uni-goettingen.de
http://www.rdd.sub.uni-goettingen.de
http://dhd-blog.org
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-05-20 16:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-08 9:35 Placing margin notes on the left using Lua Hannes Riebl
2015-05-08 10:17 ` Wolfgang Schuster
2015-05-08 10:36 ` Hannes Riebl
2015-05-08 10:41 ` Wolfgang Schuster
2015-05-08 11:14 ` Hannes Riebl
2015-05-20 15:14 ` Hannes Riebl
2015-05-20 15:21 ` luigi scarso
2015-05-20 16:44 ` Hannes Riebl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).