LaTeX forum ⇒ OthersHow can I use a keyval as parameter for minted?

Information and discussion about other tools not listed above.
acombo
Posts: 2
Joined: Fri Apr 20, 2012 10:32 am

How can I use a keyval as parameter for minted?

Postby acombo » Mon Nov 21, 2016 5:23 pm

I'm trying to use minted inclusion of source code in a document. Everything works fine if I write (or use a command) as the filename, but if I first store the filename in a key (using keyval) an error occurs and mint does not recognizes the file. Bellow is the code... and the line (commented) that gives the error, and the error itself. Thanks for you help.

  1. \documentclass{article}
  2.  
  3. % Preamble Setting for {minted} package
  4. \usepackage{minted}
  5. \usemintedstyle{friendly}
  6. % Specify Custom Styles for minted Source Codes
  7. \newmintedfile[codec]{c}{linenos=true}
  8.  
  9. \usepackage{keyval}% <!-- m --><a class="postlink" href="http://ctan.org/pkg/keyval">http://ctan.org/pkg/keyval</a><!-- m -->
  10.  
  11. \newcommand{\tempsrc}{./tmpsrc/} % Just a path!
  12. \newcounter{cntTmp}
  13.  
  14. \makeatletter
  15. \newcommand{\gitRepoDir}{S:/temp/git_test/}
  16. \newcommand{\tmpSrcDir}{./tmpsrc/}
  17. \newcommand{\mysome}[1]{#1}
  18. % \gFile{<Init Directory>}{<Tag>}{<Source Directory>}{Filename}
  19. \newcommand{\gFile}[4]{
  20. % Define Key
  21. \define@key{}{fdTmp\arabic{cntTmp}}[]{tmp#2#4}
  22. \stepcounter{cntTmp}
  23. }
  24. \makeatother
  25. \begin{document}
  26. - Add a key.
  27. \gFile{src}{first-tag}{./}{test.txt}
  28. - End Key creation. \newline
  29. - Verify SETKEYS (for fdTmp0): \setkeys{}{fdTmp0} \newline
  30. -- At this point assume the following files exist:\newline
  31. +++++ \setkeys{}{fdTmp0} \newline
  32. - Now the minted command WITH file name.
  33. \codec[firstline=5, lastline=50]{\tempsrc tmpfirst-tagtest.txt}
  34.  
  35. - Now the same command, but where the parameter is given by setkeys.
  36.  
  37. %%% HERE LIES THE PROBLEM
  38. %\codec[firstline=5, lastline=50]{\tempsrc \setkeys{}{fdTmp0}}
  39.  
  40. % The following error appears if the above line is added:
  41. % Traceback (most recent call last): File "<string>", line 1, in <module> IOError: [Errno 2] No such file or directory: './tmpsrc/\\def KV@FV@{KV@@}\\let \\par '
  42.  
  43.  
  44. \end{document}

Return to “Others”

Who is online

Users browsing this forum: No registered users and 2 guests