diff options
author | Robert Alessi <alessi@robertalessi.net> | 2018-11-07 22:10:25 +0100 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2018-11-07 22:10:25 +0100 |
commit | bb6c3f74b7794ee3213e370cbf35dc8a1a7c3849 (patch) | |
tree | b2ff400ad2d206cf0ee9b8e0664ddb5548e285e0 | |
parent | f90f5db3dd3b83d5d61643fb1a8badf8478a34c9 (diff) | |
download | ekdosis-bb6c3f74b7794ee3213e370cbf35dc8a1a7c3849.tar.gz |
get rid of afterpage (reimplementation of ekdosis)
-rw-r--r-- | ekdosis.dtx | 139 |
1 files changed, 103 insertions, 36 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx index cc31f61..165a9a6 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx | |||
@@ -328,8 +328,9 @@ Running "make install" installs the files in the local TeX tree. | |||
328 | \RequirePackage[addpageno]{lineno} | 328 | \RequirePackage[addpageno]{lineno} |
329 | \RequirePackage{vplref} | 329 | \RequirePackage{vplref} |
330 | \RequirePackage{keyfloat} | 330 | \RequirePackage{keyfloat} |
331 | \RequirePackage{afterpage} | 331 | % \RequirePackage{afterpage} |
332 | \RequirePackage{refcount} | 332 | \RequirePackage{refcount} |
333 | \RequirePackage[user,abspage]{zref} | ||
333 | \if@pkg@parnotes | 334 | \if@pkg@parnotes |
334 | \RequirePackage{parnotes} | 335 | \RequirePackage{parnotes} |
335 | \fi | 336 | \fi |
@@ -343,22 +344,48 @@ Running "make install" installs the files in the local TeX tree. | |||
343 | % \end{macrocode} | 344 | % \end{macrocode} |
344 | % \begin{macrocode} | 345 | % \begin{macrocode} |
345 | \newbool{isapp} | 346 | \newbool{isapp} |
347 | \newbool{doapp} | ||
346 | \newbool{ekdstate} | 348 | \newbool{ekdstate} |
347 | \newbool{ekdstarted} | 349 | % \newbool{ekdstarted} |
348 | \providebool{al@rlmode} | 350 | \providebool{al@rlmode} |
349 | \newcounter{ekd@lab} | 351 | \newcounter{ekd@lab} |
352 | \def\blfootnote{\gdef\@thefnmark{\relax}\@footnotetext} | ||
353 | \def\add@@apparatus{% | ||
354 | % \blfootnote{\apparatus}% | ||
355 | \if@pkg@parnotes\parnotes\else\fi% | ||
356 | \keyparbox[b!]{}{% | ||
357 | \rule{5cm}{0.5pt}\\ | ||
358 | \if@pkg@parnotes% | ||
359 | \if@parnotesroman% | ||
360 | \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi% | ||
361 | \parnoteclear\else\fi% | ||
362 | \footnotesize\apparatus% | ||
363 | \if@pkg@parnotes\parnotes\parnotereset\else\fi% | ||
364 | }% | ||
365 | } | ||
366 | \def\add@apparatus{% | ||
367 | \ifbool{isapp}{\testapparatus}{\add@@apparatus% | ||
368 | \global\setbool{isapp}{true}}% | ||
369 | \ifbool{doapp}{\add@@apparatus}{}% | ||
370 | } | ||
350 | \NewDocumentCommand{\append}{+m}{% | 371 | \NewDocumentCommand{\append}{+m}{% |
351 | \ifbool{ekdstate}{% | 372 | \ifbool{ekdstate}{% |
352 | \label{ekd:\theekd@lab}% | 373 | \luadirect{appin(\luastring{<\zref@extract{ekd:\theekd@lab}{abspage}>}, |
353 | \luadirect{appin(\luastring{<\getpagerefnumber{ekd:\theekd@lab}>}, | ||
354 | "no")}% | 374 | "no")}% |
355 | \luadirect{appin(\luastringN{#1}, "no")}% | 375 | \luadirect{appin(\luastringN{#1}, "no")}% |
356 | \luadirect{appin(\luastring{</\getpagerefnumber{ekd:\theekd@lab}>}, | 376 | \luadirect{appin(\luastring{</\zref@extract{ekd:\theekd@lab}{abspage}>}, |
357 | "yes")}% | 377 | "yes")}% |
358 | \stepcounter{ekd@lab}}{}} | 378 | }{}} |
359 | \NewDocumentCommand{\obappend}{+m}% | 379 | \NewDocumentCommand{\obappend}{+m}% |
360 | {\luadirect{tex.sprint(ekdosis.mdvappend(\luastringN{#1}))}} | 380 | {\luadirect{tex.sprint(ekdosis.mdvappend(\luastringN{#1}))}} |
361 | \NewDocumentCommand{\app}{+m}{#1} | 381 | \NewDocumentCommand{\app}{+m}{% |
382 | \stepcounter{ekd@lab}% | ||
383 | \zlabel{ekd:\theekd@lab}% | ||
384 | \luadirect{% | ||
385 | ekdosis.storeabspg(\luastring{\zref@extract{ekd:\theekd@lab}{abspage}}, | ||
386 | "pg_ii")}% | ||
387 | \add@apparatus% | ||
388 | #1} | ||
362 | \NewDocumentCommand{\lem}{o +m}{% | 389 | \NewDocumentCommand{\lem}{o +m}{% |
363 | \ifbool{al@rlmode}% | 390 | \ifbool{al@rlmode}% |
364 | {\IfNoValueTF{#1}% | 391 | {\IfNoValueTF{#1}% |
@@ -380,34 +407,29 @@ Running "make install" installs the files in the local TeX tree. | |||
380 | } | 407 | } |
381 | \NewDocumentCommand{\apparatus}{}{\luadirect{tex.sprint(appout())}} | 408 | \NewDocumentCommand{\apparatus}{}{\luadirect{tex.sprint(appout())}} |
382 | \NewDocumentCommand{\testapparatus}{}{% | 409 | \NewDocumentCommand{\testapparatus}{}{% |
383 | \luadirect{tex.sprint(testapparatus())}} | 410 | \luadirect{tex.sprint(ekdosis.testapparatus())}} |
384 | \def\blfootnote{\gdef\@thefnmark{\relax}\@footnotetext} | 411 | % \def\add@apparatus{% |
385 | \def\add@@apparatus{% | 412 | % \add@@apparatus% |
386 | \testapparatus% | 413 | % \afterpage{\add@apparatus}} |
387 | \ifbool{isapp}{% | 414 | % \NewDocumentCommand{\EkdosisStart}{}{% |
388 | % \blfootnote{\apparatus}% | 415 | % \add@@apparatus% |
389 | \if@pkg@parnotes\parnotes\else\fi% | 416 | % \afterpage{\add@apparatus}} |
390 | \keyparbox[b!]{}{% | ||
391 | \rule{5cm}{0.5pt}\\ | ||
392 | \if@pkg@parnotes% | ||
393 | \if@parnotesroman% | ||
394 | \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi% | ||
395 | \parnoteclear\else\fi% | ||
396 | \footnotesize\apparatus% | ||
397 | \if@pkg@parnotes\parnotes\parnotereset\else\fi% | ||
398 | }% | ||
399 | }{}} | ||
400 | \def\add@apparatus{% | ||
401 | \add@@apparatus% | ||
402 | \afterpage{\add@apparatus}} | ||
403 | \NewDocumentCommand{\EkdosisStart}{}{% | 417 | \NewDocumentCommand{\EkdosisStart}{}{% |
404 | \add@@apparatus% | 418 | \stepcounter{ekd@lab}% |
405 | \afterpage{\add@apparatus}} | 419 | \zlabel{ekd:\theekd@lab}% |
420 | \luadirect{% | ||
421 | ekdosis.storeabspg(\luastring{\zref@extract{ekd:\theekd@lab}{abspage}}, | ||
422 | "pg_i")}% | ||
423 | } | ||
406 | \NewDocumentCommand{\EkdosisOn}{}{\setbool{ekdstate}{true}} | 424 | \NewDocumentCommand{\EkdosisOn}{}{\setbool{ekdstate}{true}} |
407 | \NewDocumentCommand{\EkdosisOff}{}{\setbool{ekdstate}{false}} | 425 | \NewDocumentCommand{\EkdosisOff}{}{% |
426 | \setbool{ekdstate}{false}% | ||
427 | \global\setbool{isapp}{false}% | ||
428 | } | ||
408 | \newenvironment{ekdosis}{% | 429 | \newenvironment{ekdosis}{% |
409 | \ifbool{ekdstarted}{}{\EkdosisStart\global\setbool{ekdstarted}{true}} | 430 | % \ifbool{ekdstarted}{}{\EkdosisStart\global\setbool{ekdstarted}{true}} |
410 | \EkdosisOn}{\EkdosisOff} | 431 | \EkdosisStart% |
432 | \EkdosisOn}{\EkdosisOff} | ||
411 | % \end{macrocode} | 433 | % \end{macrocode} |
412 | % \iffalse | 434 | % \iffalse |
413 | %</package> | 435 | %</package> |
@@ -431,6 +453,37 @@ function remove() | |||
431 | os.remove(tex.jobname..".ekd") | 453 | os.remove(tex.jobname..".ekd") |
432 | end | 454 | end |
433 | 455 | ||
456 | local pg_i = 0 | ||
457 | local pg_ii = 0 | ||
458 | local cur_abs_pg = 0 | ||
459 | |||
460 | ekdosis.update_abspg = function(n) | ||
461 | cur_abs_pg = n | ||
462 | return true | ||
463 | end | ||
464 | |||
465 | ekdosis.get_abs_page = function() | ||
466 | return cur_abs_pg | ||
467 | end | ||
468 | |||
469 | ekdosis.storeabspg = function(n, pg) | ||
470 | if pg == "pg_i" then | ||
471 | pg_i = n | ||
472 | elseif pg == "pg_ii" then | ||
473 | pg_ii = n | ||
474 | end | ||
475 | cur_abs_pg = n | ||
476 | return true | ||
477 | end | ||
478 | |||
479 | ekdosis.getabspg = function(pg) --not used | ||
480 | if pg == "pg_i" then | ||
481 | return pg_i | ||
482 | elseif pg == "pg_ii" then | ||
483 | return pg_ii | ||
484 | end | ||
485 | end | ||
486 | |||
434 | function isintable(table, value) | 487 | function isintable(table, value) |
435 | for _, v in pairs(table) do | 488 | for _, v in pairs(table) do |
436 | if v == value then return true end | 489 | if v == value then return true end |
@@ -456,18 +509,19 @@ function appout() | |||
456 | t = f:read("*a") | 509 | t = f:read("*a") |
457 | local output = {} | 510 | local output = {} |
458 | for i in string.gmatch(t, | 511 | for i in string.gmatch(t, |
459 | "<"..tex.count[0]..">.-</"..tex.count[0]..">") | 512 | "<"..cur_abs_pg..">.-</"..cur_abs_pg..">") |
460 | do | 513 | do |
461 | table.insert(output, i) | 514 | table.insert(output, i) |
462 | end | 515 | end |
463 | f:close() | 516 | f:close() |
464 | str = table.concat(output, "\n") | 517 | str = table.concat(output, "\n") |
465 | str = string.gsub(str, "</"..tex.count[0]..">", " ") | 518 | str = string.gsub(str, "</"..cur_abs_pg..">", " ") |
466 | str = string.gsub(str, "<"..tex.count[0]..">", "") | 519 | str = string.gsub(str, "<"..cur_abs_pg..">", "") |
467 | return str | 520 | return str |
468 | else end | 521 | else end |
469 | end | 522 | end |
470 | 523 | ||
524 | --[[ | ||
471 | function testapparatus() | 525 | function testapparatus() |
472 | local file = io.open(tex.jobname..".ekd", "r") | 526 | local file = io.open(tex.jobname..".ekd", "r") |
473 | if file ~= nil then | 527 | if file ~= nil then |
@@ -477,6 +531,17 @@ function testapparatus() | |||
477 | else return "\\boolfalse{isapp}" end | 531 | else return "\\boolfalse{isapp}" end |
478 | file:close() | 532 | file:close() |
479 | end | 533 | end |
534 | --]] | ||
535 | |||
536 | ekdosis.testapparatus = function() | ||
537 | if pg_ii == pg_i then | ||
538 | return "\\boolfalse{doapp}" | ||
539 | elseif pg_ii > pg_i then | ||
540 | return "\\booltrue{doapp}" | ||
541 | else | ||
542 | return "\\boolfalse{doapp}" | ||
543 | end | ||
544 | end | ||
480 | 545 | ||
481 | md5items = {} | 546 | md5items = {} |
482 | local salt = 0 | 547 | local salt = 0 |
@@ -490,7 +555,9 @@ ekdosis.mdvappend = function(str) | |||
490 | table.insert(md5items, i) | 555 | table.insert(md5items, i) |
491 | salt = salt + 1 | 556 | salt = salt + 1 |
492 | end | 557 | end |
493 | return "\\linelabel{"..i.."}\\append{\\textbf{\\getrefnumber{"..i.."}} "..str.."}" | 558 | return "\\linelabel{"..i.."}" |
559 | .. | ||
560 | "\\append{\\textbf{\\getrefnumber{"..i.."}} "..str.."}" | ||
494 | end | 561 | end |
495 | 562 | ||
496 | --[[ -- of no use | 563 | --[[ -- of no use |