我有我的项目的当前文件夹结构
.
├── Makefile
└── S6
├── CD_CS304.md
├── CN_CS306.md
├── DAA_CS302.md
└── graphviz
└── cs304_compilerphases.dot
2 directories, 5 files我正在为每个markdown文件构建单独的pdf,这是我的Makefile
# Generate PDFs from the Markdown source files
#
# In order to use this makefile, you need some tools:
# - GNU make
# - Pandoc
# All markdown files are considered sources
MD_SOURCES := $(wildcard **/*.md)
OUTPUT_PDFS := $(MD_SOURCES:.md=.pdf)
DOT_SOURCES := $(wildcard **/*.dot)
OUTPUT_DOTPNGS := $(DOT_SOURCES:.dot=.png)
all: $(OUTPUT_DOTPNGS) $(OUTPUT_PDFS)
# Recipe for building png files from dot files
%.png: %.dot
dot \
-Tpng $< \
-o $@
# Recipe for converting a Markdown file into PDF using Pandoc
%.pdf: %.md
pandoc \
--variable fontsize=12pt \
--variable date:"\today" \
--variable geometry:a4paper \
--variable documentclass:book \
--table-of-contents \
--number-sections \
--filter pandoc-fignos \
-f markdown $< \
-o $@
.PHONY : clean
clean: $(OUTPUT_PDFS) $(OUTPUT_DOTPNGS)
$(RM) $^我想将点程序的输出嵌入到latex的pdf中,但在这里,Makefile没有将点文件转换为png,而是直接编译pdf。
这会使pdf编译遇到错误,因为png文件不存在。
发布于 2019-02-03 12:37:58
如果要确保一个文件在另一个文件之前生成,请添加依赖项。
更改此设置:
%.pdf: %.md要这样做:
%.pdf: %.md $(OUTPUT_DOTPNGS)这个依赖关系告诉我们,“除非您已经构建了每个png文件,否则不要构建这个pdf文件。”
https://stackoverflow.com/questions/54499899
复制相似问题