Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. documentclass{minimal}
  2. makeatletter
  3. defapp@exe{immediatewrite18}
  4. definputAllFiles#1{%
  5. app@exe{ls #1/*.txt | xargs cat >> jobname.tmp}%
  6. InputIfFileExists{jobname.tmp}{}
  7. AtEndDocument{app@exe{rm -f #1/jobname.tmp}}}
  8. makeatother
  9. begin{document}
  10.  
  11. inputAllFiles{.}% from the current dir
  12.  
  13. end{document}
  14.  
  15. documentclass{article}
  16.  
  17. newcommand*{MaxNumOfChapters}{10}% Adjust these two settings for your needs.
  18. newcommand*{MaxNumOfSections}{6}%
  19.  
  20. usepackage{pgffor}%
  21.  
  22. begin{document}
  23. foreach c in {1,2,...,MaxNumOfChapters}{%
  24. foreach s in {1,2,...,MaxNumOfSections}{%
  25. IfFileExists{Chapterc/Sections} {%
  26. input{Chapterc/Sections}%
  27. }{%
  28. % files does not exist, so nothing to do
  29. }%
  30. }%
  31. }%
  32. end{document}
  33.  
  34. newcommand*{ListOfFiles}{%
  35. Chapter1/Section1,
  36. Chapter1/Section2,
  37. Chapter1/Section3,
  38. Chapter2/Section1,
  39. Chapter2/Section2
  40. }%
  41.  
  42. documentclass{article}%
  43. usepackage{pgffor}%
  44.  
  45. input{ListOfFiles}%
  46.  
  47. begin{document}%
  48. foreach c in ListOfFiles {%
  49. input{c}%
  50. }%
  51. end{document}
  52.  
  53. directlua{dofile("inputall.lua")}
  54.  
  55. bye
  56.  
  57. function dirtree(dir)
  58.  
  59. if string.sub(dir, -1) == "/" then
  60. dir=string.sub(dir, 1, -2)
  61. end
  62.  
  63. local function yieldtree(dir)
  64. for entry in lfs.dir(dir) do
  65. if not entry:match("^%.") then
  66. entry=dir.."/"..entry
  67. if lfs.isdir(entry) then
  68. yieldtree(entry)
  69. else
  70. coroutine.yield(entry)
  71. end
  72. end
  73. end
  74. end
  75.  
  76. return coroutine.wrap(function() yieldtree(dir) end)
  77. end
  78.  
  79.  
  80. for i in dirtree(lfs.currentdir()) do
  81. local filename = i:gsub(".*/([^/]+)$","%1")
  82. tex.sprint("\input " .. filename .. " ")
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement