Commit a0f6a889c977c4b54094b6c414857534b3c24862
1 parent
d8099aa8
*** empty log message ***
Showing
2 changed files
with
84 additions
and
111 deletions
Show diff stats
anubis_dev/library/tools/latex.anubis
| ... | ... | @@ -77,27 +77,36 @@ public type LaTeX_Title: |
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | |
| 80 | + Il est possible demander la mise en place d'une table des matières. Dans l'affirmative, | |
| 81 | + il faut donner le nom de la langue qui sera utilisé dans : \selectlanguage{}. | |
| 82 | + | |
| 83 | +public type LaTeX_Table_of_Contents: | |
| 84 | + none, | |
| 85 | + table_of_contents (String). | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 80 | 89 | La fonction permettant de créer le fichier PDF est : |
| 81 | 90 | |
| 82 | 91 | |
| 83 | 92 | public define ResultMakePdf |
| 84 | 93 | make_pdf_file |
| 85 | 94 | ( |
| 86 | - String more_ahead, | |
| 87 | - LaTeX_Title title, | |
| 88 | - String core, | |
| 89 | - Bool table_of_contents, | |
| 90 | - String colors, | |
| 91 | - String file_name, | |
| 92 | - Maybe(String) mb_execution_directory, | |
| 93 | - Maybe(String) mb_pdf_directory | |
| 95 | + String more_ahead, | |
| 96 | + LaTeX_Title title, | |
| 97 | + String core, | |
| 98 | + LaTeX_Table_of_Contents toc, | |
| 99 | + String colors, | |
| 100 | + String file_name, | |
| 101 | + Maybe(String) mb_execution_directory, | |
| 102 | + Maybe(String) mb_pdf_directory | |
| 94 | 103 | ). |
| 95 | 104 | |
| 96 | 105 | Avec : |
| 97 | 106 | 'more_ahead' : figurera dans l'en tête, en sus des éléments de bases |
| 98 | 107 | 'title' : cf ci-dessus |
| 99 | 108 | 'core' : contenu (en LaTeX) qui doit se trouver entre \begin{document} et \end{document} |
| 100 | - 'table_of_contents' : indicateur de la présence ou non d'un sommaire créé à partif de \makeindex | |
| 109 | + 'toc : cf ci-dessus | |
| 101 | 110 | 'colors' : les éventuels \\definecolor{}{}{} pour les couleurs utilisées dans 'core' |
| 102 | 111 | |
| 103 | 112 | Les trois autres composants sont identiques à la version précédente de 'make_pdf_file'. |
| ... | ... | @@ -269,7 +278,7 @@ define String |
| 269 | 278 | //+ "\\usepackage{longtable}\n" |
| 270 | 279 | + "\\usepackage{fancyhdr}\n" |
| 271 | 280 | + "\\fancyhead{}\n" |
| 272 | - + "\\fancyhead[LE]{\\thepage \\hfill \\textsl{Section \leftmark}}\n" | |
| 281 | + + "\\fancyhead[LE]{\\thepage \\hfill \\textsl{ \leftmark}}\n" | |
| 273 | 282 | + "\\fancyhead[RO]{\\textsl{\\rightmark} \\hfill \\thepage}\n" |
| 274 | 283 | + "\\fancyfoot{}\n" |
| 275 | 284 | + "\\pagestyle{fancy}\n" |
| ... | ... | @@ -291,11 +300,11 @@ define String |
| 291 | 300 | public define String |
| 292 | 301 | latex_page |
| 293 | 302 | ( |
| 294 | - String more_ahead, | |
| 295 | - LaTeX_Title title, | |
| 296 | - String text_from_maml, | |
| 297 | - Bool table_of_contents, | |
| 298 | - String colors, | |
| 303 | + String more_ahead, | |
| 304 | + LaTeX_Title title, | |
| 305 | + String text_from_maml, | |
| 306 | + LaTeX_Table_of_Contents toc, | |
| 307 | + String colors, | |
| 299 | 308 | ) = |
| 300 | 309 | latex_head(more_ahead |
| 301 | 310 | + if title is |
| ... | ... | @@ -318,7 +327,11 @@ public define String |
| 318 | 327 | predefined(_,_) then "\\maketitle \n \\thispagestyle{empty} \n \\newpage \n ", |
| 319 | 328 | free_title(t) then t+" \n \\thispagestyle{empty} \n \\newpage \n " |
| 320 | 329 | } |
| 321 | - + (if table_of_contents then "\\tableofcontents \n \\newpage \n" else "") | |
| 330 | + + if toc is | |
| 331 | + { | |
| 332 | + none then "" | |
| 333 | + table_of_contents(lang) then "\selectlanguage{"+lang+"}\\tableofcontents \n \\newpage \n" | |
| 334 | + } | |
| 322 | 335 | + text_from_maml |
| 323 | 336 | + "\n\n" |
| 324 | 337 | + "\\end{sloppypar}\n\n" |
| ... | ... | @@ -425,14 +438,14 @@ public define ResultMakePdf |
| 425 | 438 | define ResultMakePdf |
| 426 | 439 | make_pdf_file |
| 427 | 440 | ( |
| 428 | - String more_ahead, | |
| 429 | - LaTeX_Title title, | |
| 430 | - String core, | |
| 431 | - Bool table_of_contents, | |
| 432 | - String colors, | |
| 433 | - String file_name, | |
| 434 | - Maybe(String) mb_execution_directory, | |
| 435 | - Maybe(String) mb_pdf_directory | |
| 441 | + String more_ahead, | |
| 442 | + LaTeX_Title title, | |
| 443 | + String core, | |
| 444 | + LaTeX_Table_of_Contents toc, | |
| 445 | + String colors, | |
| 446 | + String file_name, | |
| 447 | + Maybe(String) mb_execution_directory, | |
| 448 | + Maybe(String) mb_pdf_directory | |
| 436 | 449 | ) = |
| 437 | 450 | if write_to_file |
| 438 | 451 | (if mb_execution_directory is |
| ... | ... | @@ -440,75 +453,20 @@ define ResultMakePdf |
| 440 | 453 | failure then "", |
| 441 | 454 | success(s) then s |
| 442 | 455 | }+"/"+file_name+".tex", |
| 443 | - to_byte_array(latex_page(more_ahead,title,core,table_of_contents,colors))) is | |
| 456 | + to_byte_array(latex_page(more_ahead,title,core,toc,colors))) is | |
| 444 | 457 | { |
| 445 | 458 | cannot_open_file then cannot_create_tex, |
| 446 | 459 | write_error(_) then cannot_create_tex, |
| 447 | - ok then make_pdf_file(file_name,mb_execution_directory,mb_pdf_directory, | |
| 448 | - if table_of_contents then 2 else 1) | |
| 460 | + ok then | |
| 461 | + make_pdf_file(file_name,mb_execution_directory,mb_pdf_directory, | |
| 462 | + if toc is | |
| 463 | + { | |
| 464 | + none then 1 | |
| 465 | + table_of_contents(_) then 2 | |
| 466 | + }) | |
| 449 | 467 | }. |
| 450 | 468 | |
| 451 | 469 | |
| 452 | - Résultat -> One | |
| 453 | - --------------- | |
| 454 | - | |
| 455 | - | |
| 456 | - define One | |
| 457 | - make_pdf_file | |
| 458 | - ( | |
| 459 | - String file_name, | |
| 460 | - Maybe(String) mb_execution_directory, | |
| 461 | - Maybe(String) mb_pdf_directory, | |
| 462 | - ) = | |
| 463 | - if (Maybe(ExecuteControl))execute(mb_execution_directory,"dvipdf",[file_name+".dvi"]) is | |
| 464 | - { | |
| 465 | - failure then print("Error execute making pdf file \n"), | |
| 466 | - success(ec) then | |
| 467 | - print("dvipdf : "); | |
| 468 | - if execute_control(ec,now+30) | |
| 469 | - then print("OK \n"); | |
| 470 | - if mb_pdf_directory is | |
| 471 | - { | |
| 472 | - failure then unique, | |
| 473 | - success(pdf_dir) then | |
| 474 | - if (Maybe(ExecuteControl))execute(mb_execution_directory,"mv",[file_name+".pdf",pdf_dir]) is | |
| 475 | - { | |
| 476 | - failure then print("Error execute mv pdf \n"), | |
| 477 | - success(mv) then | |
| 478 | - print("mv pdf file -> pdf_directory : "); | |
| 479 | - if execute_control(mv,now+10) | |
| 480 | - then print("OK \n") | |
| 481 | - else print("Error mv PDF \n") | |
| 482 | - }} | |
| 483 | - | |
| 484 | - else print("Error making pdf file \n") | |
| 485 | - }. | |
| 486 | - | |
| 487 | - | |
| 488 | - public define One | |
| 489 | - latex_compilation | |
| 490 | - ( | |
| 491 | - String file_name, // without extension | |
| 492 | - Maybe(String) mb_execution_directory, | |
| 493 | - Maybe(String) mb_pdf_directory, | |
| 494 | - Int32 compilation_number // 2 if table-of-contents is required | |
| 495 | - ) = | |
| 496 | - if (Maybe(ExecuteControl)) | |
| 497 | - execute(mb_execution_directory,"latex",[file_name+".tex"]) is | |
| 498 | - { | |
| 499 | - failure then print("Error executing compilation n°"+compilation_number+"\n"), | |
| 500 | - success(ec) then | |
| 501 | - print("Compilation n°"+compilation_number+" : "); | |
| 502 | - if execute_control(ec,now+60) | |
| 503 | - then print("OK\n"); | |
| 504 | - if compilation_number = 1 | |
| 505 | - then make_pdf_file(file_name,mb_execution_directory,mb_pdf_directory) | |
| 506 | - else latex_compilation(file_name,mb_execution_directory, | |
| 507 | - mb_pdf_directory,compilation_number-1) | |
| 508 | - else print("Error compilation n°"+compilation_number+"\n") | |
| 509 | - }. | |
| 510 | - | |
| 511 | - | |
| 512 | 470 | |
| 513 | 471 | |
| 514 | 472 | |
| ... | ... | @@ -565,14 +523,14 @@ public define One |
| 565 | 523 | public define One |
| 566 | 524 | make_pdf_file |
| 567 | 525 | ( |
| 568 | - String more_ahead, | |
| 569 | - LaTeX_Title title, | |
| 570 | - String core, | |
| 571 | - Bool table_of_contents, | |
| 572 | - String colors, | |
| 573 | - String file_name, | |
| 574 | - Maybe(String) mb_execution_directory, | |
| 575 | - Maybe(String) mb_pdf_directory | |
| 526 | + String more_ahead, | |
| 527 | + LaTeX_Title title, | |
| 528 | + String core, | |
| 529 | + LaTeX_Table_of_Contents toc, | |
| 530 | + String colors, | |
| 531 | + String file_name, | |
| 532 | + Maybe(String) mb_execution_directory, | |
| 533 | + Maybe(String) mb_pdf_directory | |
| 576 | 534 | ) = |
| 577 | 535 | if write_to_file |
| 578 | 536 | (if mb_execution_directory is |
| ... | ... | @@ -580,12 +538,16 @@ public define One |
| 580 | 538 | failure then "", |
| 581 | 539 | success(s) then s |
| 582 | 540 | }+"/"+file_name+".tex", |
| 583 | - to_byte_array(latex_page(more_ahead,title,core,table_of_contents,colors))) is | |
| 541 | + to_byte_array(latex_page(more_ahead,title,core,toc,colors))) is | |
| 584 | 542 | { |
| 585 | 543 | cannot_open_file then print("COF \n"), |
| 586 | 544 | write_error(_) then print("WE \n"), |
| 587 | 545 | ok then |
| 588 | 546 | latex_compilation(file_name,mb_execution_directory,mb_pdf_directory, |
| 589 | - if table_of_contents then 2 else 1) | |
| 547 | + if toc is | |
| 548 | + { | |
| 549 | + none then 1 | |
| 550 | + table_of_contents(_) then 2 | |
| 551 | + }) | |
| 590 | 552 | }. |
| 591 | 553 | ... | ... |
anubis_dev/library/tools/maml.anubis
| ... | ... | @@ -775,17 +775,30 @@ define String |
| 775 | 775 | { |
| 776 | 776 | [] then end_code_color, |
| 777 | 777 | [h . t] then |
| 778 | - (if h = ' ' then "\\ " else | |
| 779 | - if h = '\n' then | |
| 780 | - if sub_environment is // { | |
| 778 | + with next_step = (List(Int8) li) |-> | |
| 779 | + format_code_with_color2(li,sub_environment,begin_code_color,end_code_color), | |
| 780 | + if h = ' ' then ("\\ "+next_step(t)) else | |
| 781 | + if h = '\n' then | |
| 782 | + (if sub_environment is // { | |
| 783 | + { | |
| 784 | + failure then end_code_color+(if t is [] then "" else "\\\\ ")+begin_code_color, | |
| 785 | + success(s) then end_code_color+"} "+(if t is [] then "" else "\\\\ ")+begin_code_color+s | |
| 786 | + }+next_step(t)) else | |
| 787 | + if h = '|' then | |
| 788 | + if t is | |
| 781 | 789 | { |
| 782 | - failure then end_code_color+(if t is [] then "" else "\\\\ ")+begin_code_color, | |
| 783 | - success(s) then end_code_color+"} "+(if t is [] then "" else "\\\\ ")+begin_code_color+s | |
| 784 | - } else | |
| 785 | - //if h ='|' then "\\raisebox{-2.8pt}{\\rule{0.5pt}{11pt}}" else | |
| 786 | - //if h = '-' then "$-$" | |
| 787 | - transform_schar(h,latex_schar)) | |
| 788 | - + format_code_with_color2(t,sub_environment,begin_code_color,end_code_color) | |
| 790 | + [] then transform_schar(h,latex_schar)+ next_step(t), | |
| 791 | + [u . v] then | |
| 792 | + if u = '-' | |
| 793 | + then ("\\raisebox{-1.8pt}{\\rule{0.4pt}{9pt}}" | |
| 794 | + +"\\raisebox{2.4pt}{\\rule{3pt}{0pt}}" | |
| 795 | + +"\\raisebox{2.6pt}{\\rule{6pt}{0.4pt}}" | |
| 796 | + +"\\raisebox{2.4pt}{\\rule{1.5pt}{0pt}}" | |
| 797 | + + next_step(v)) | |
| 798 | + else (transform_schar(h,latex_schar) | |
| 799 | + + next_step(t)) | |
| 800 | + } else | |
| 801 | + (transform_schar(h,latex_schar)+next_step(t)) | |
| 789 | 802 | }. |
| 790 | 803 | |
| 791 | 804 | define String |
| ... | ... | @@ -886,7 +899,7 @@ define Text |
| 886 | 899 | if name = "code" then |
| 887 | 900 | //t-("\\vspace{2mm}\n{\\tt" |
| 888 | 901 | t-("\\\\{\\tt" |
| 889 | - +"\\begin{tabular}{"+(if member(lenv,center)then "c" else "l")+"}\n") | |
| 902 | + +"\\begin{tabular}{l}\n") | |
| 890 | 903 | -code_to_LaTeX(m1,sub_environment,site_name,public_dir,lenv) |
| 891 | 904 | -" \\end{tabular}}\\\\ \n" else |
| 892 | 905 | |
| ... | ... | @@ -1006,11 +1019,9 @@ public define Text |
| 1006 | 1019 | |
| 1007 | 1020 | if name = "code" then |
| 1008 | 1021 | t-((if member(lenv,center) then "" else "\n")+s_en(unique)+"\n{\\tt" |
| 1009 | - //+ "\\begin{tabular}{"+(if member(lenv,center) then "c" else "l")+"}\n") | |
| 1010 | 1022 | + "\\begin{tabular}{l}\n") |
| 1011 | 1023 | -code_to_LaTeX(a1,failure,site_name,public_dir,[]) |
| 1012 | - -("\\end{tabular}}\\vspace{0.4cm}"+us_en(unique)+ | |
| 1013 | - "\n\n") else | |
| 1024 | + -("\\end{tabular}}\\vspace{0.4cm}"+us_en(unique)+"\n\n") else | |
| 1014 | 1025 | |
| 1015 | 1026 | if name = "center" then |
| 1016 | 1027 | t-"\\begin{center} " | ... | ... |