I write/collect some codes (e.g., C, R or Matlab) in a subdirectory named, say, myCodes. Then I want to use VerbatimInput from usepackage{fancyvrb} to list the codes in some absolute path way. I know the graphicspath from usepackage{graphicx} can do this work for figures. How the same issue can be solved for codes? My .tex file reads

% ================= figure================ 
% ================= code================ 
%\codespath{{./myCodes/}} %??????


%\VerbatimInput[label=hello.c]{hello.c} %??????


And my sample C code hello.c reads

#include <stdio.h>
int main(void)
    printf("Hello, world!\n"); 
    return 0;

According to Christian Hupfer, I mimic that as


Then I use


but it still doesn't work.

  • Welcome to TeX.SX! Implementing path prefixes is something really difficult. Even graphicspath is not perfect. – TeXnician Jun 16 '18 at 10:02
  • Welcome to TeX - LaTeX! There is no default mechanism set-up for this. The graphicspath code is fairly complicated, but could be emulated. Do you need just one directory or a whole list? – Andrew Swann Jun 16 '18 at 10:03
  • Tks anyway@ TeXnician@ Andrew Swann – John Stone Jun 16 '18 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.