Guest User

Untitled

a guest
Oct 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. %& -jobname=output
  2. documentclass{book}
  3.  
  4. usepackage{tikz,pgfplots}
  5. usetikzlibrary{external}
  6. tikzset{external/only named=true}
  7. pgfplotsset{compat=newest}
  8.  
  9. tikzexternalize
  10.  
  11. begin{document}
  12.  
  13. begin{figure}[h]
  14. tikzsetnextfilename{sample_tikz}
  15. begin{tikzpicture}[scale=1.50]
  16. begin{axis}addplot {x^3};end{axis}
  17. end{tikzpicture}
  18. caption{Sample tikz picture.}
  19. end{figure}
  20.  
  21. end{document}
  22.  
  23. ===== 'mode=convert with system call': Invoking 'pdflatex -shell-escape -halt-o
  24. n-error -interaction=batchmode -jobname "sample_tikz" "deftikzexternalrealjob
  25. {output}input{output}"' ========
  26.  
  27. ! Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
  28. rror -interaction=batchmode -jobname "sample_tikz" "deftikzexternalrealjob{ou
  29. tput}input{output}"' did NOT result in a usable output file 'sample_tikz' (exp
  30. ected one of .pdf:.jpg:.jpeg:.png:).
  31.  
  32. pdflatex tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "image" "texsource"
  33.  
  34. stringdefstringtikzexternalrealjob{tikzexternal@realjob}stringinput{tikzexternal@realjob}
  35.  
  36. deftikzexternalrealjob{output}input{output}
  37.  
  38. deftikzexternalrealjob{output}input{main}
  39.  
  40. %& -jobname=output -recorder
  41. documentclass{book}
  42.  
  43. usepackage{tikz,pgfplots}
  44. usetikzlibrary{external}
  45. tikzset{external/only named=true}
  46. pgfplotsset{compat=newest}
  47.  
  48. input{externalize-hack.tex} % <---- THIS WAS ADDED
  49.  
  50. tikzexternalize
  51.  
  52. begin{document}
  53.  
  54. begin{figure}[h]
  55. tikzsetnextfilename{sample_tikz}
  56. begin{tikzpicture}[scale=1.50]
  57. begin{axis}addplot {x^3};end{axis}
  58. end{tikzpicture}
  59. caption{Sample tikz picture.}
  60. end{figure}
  61.  
  62. end{document}
  63.  
  64. usepackage{currfile-abspath}
  65. getmainfile
  66.  
  67. usepackage{xpatch}
  68.  
  69. makeatletter
  70.  
  71. AtEndDocument{%
  72. newwritemaindeffile%
  73. immediateopenoutmaindeffile=jobname.maindef%
  74. immediatewritemaindeffile{%
  75. noexpandifcsname mymainfilenoexpandendcsnamenoexpandelse%
  76. noexpandgdefnoexpandmymainfile{mymainfile}%
  77. noexpandfi%
  78. }%
  79. immediatecloseoutmaindeffile%
  80. }
  81.  
  82. @input{jobname.maindef}
  83.  
  84. ifcsname mymainfileendcsname%
  85. ifxmymainfile@empty%
  86. % Make a second attempt at extracting the real file name
  87. % (necessary because currfile needs two runs on MiKTeX..)
  88. filename@parse{themainfile}%
  89. letmymainfilefilename@base%
  90. ifxmymainfile@empty%
  91. % If still empty, fallback to default behavior
  92. defmymainfile{tikzexternal@realjob}%
  93. fi%
  94. fi%
  95. else%
  96. % First attempt at extracting real file name
  97. filename@parse{themainfile}%
  98. letmymainfilefilename@base%
  99. fi%
  100.  
  101. xpatchcmd{tikzexternal@assemble@systemcall}%
  102. {%
  103. edeftexsource{%
  104. stringdefstringtikzexternalrealjob{tikzexternal@realjob}%
  105. stringinput{tikzexternal@realjob}%
  106. }%
  107. }%
  108. {%
  109. edeftexsource{%
  110. stringdefstringtikzexternalrealjob{tikzexternal@realjob}%
  111. stringdefstringmymainfile{mymainfile}%
  112. stringinput{mymainfile}%
  113. }%
  114. }%
  115. {}
  116. {}
  117.  
  118. letold@tikzexternalize@opt@withnametikzexternalize@opt@withname%
  119. deftikzexternalize@opt@withname[#1]#2{%
  120. % Suppress externalization as long as mymainfile is empty
  121. % (This will only be the case the one or two first compilation runs!)
  122. ifxmymainfile@emptyelse%
  123. old@tikzexternalize@opt@withname[#1]{#2}%
  124. fi%
  125. }
  126.  
  127. makeatother
Add Comment
Please, Sign In to add comment