Include *.sty file from a super/subdirectory of main *.tex file

后端 未结 5 2059
滥情空心
滥情空心 2021-01-31 15:58

I want to share a latex document via git with many other people. Therefore we decided to put all the special sty files, that are not present in everyones latex-installation, in

5条回答
  •  感动是毒
    2021-01-31 16:11

    You can use Makefiles as suggested above. Another option is CMake. I didn't test for parent directories.

    If you have the following file structure:

        ├── CMakeLists.txt
        ├── cmake
        │   └── UseLATEX.cmake
        ├── img
        │   └── logo.jpg
        ├── lib
        │   └── framed.sty
        └── main.tex
    
    • you should have CMake installed, instructions on CMake resources

    • UseLATEX.cmake can be downloaded from here

    • then inside the CMakeLists.txt

      ╚═$ cat CMakeLists.txt
      cmake_minimum_required (VERSION 2.6)
      set(PROJECT_NAME_STR myProject)
      project(${PROJECT_NAME_STR})
      
      set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
      include(UseLATEX)
      
      ADD_LATEX_DOCUMENT(main.tex
                         IMAGE_DIRS img
                         DEFAULT_PDF
                         MANGLE_TARGET_NAMES)
      
    • Some example content for main.tex (note the image)

      ╚═$ cat main.tex
      \documentclass{report}
      
      \begin{document}
      
      \begin{center}
        \includegraphics[width=300px]{img/logo.jpg}
      \end{center}
      
      \end{document}
      
    • The lib directory has the *.sty files

    • You can now compile:

      cd /directory/that/has/CMakeLists.txt/
      mkdir build
      cd build
      cmake ..
      make
      
    • you can then view main.pdf which is in the build directory.

提交回复
热议问题