Placing margin notes on the left using Lua
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
Am 08.05.2015 um 11:35 schrieb Hannes Riebl
: 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
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
Am 08.05.2015 um 12:36 schrieb Hannes Riebl
: 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
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
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
On Wed, May 20, 2015 at 5:14 PM, Hannes Riebl
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
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
participants (3)
-
Hannes Riebl
-
luigi scarso
-
Wolfgang Schuster