制作:在目标依赖性中结合模式规则和通配符

发布于 2025-02-06 00:45:23 字数 928 浏览 3 评论 0原文

我有几个pdflatex主文件,称为ch*.tex,数字替换了Asterick,这是通过编译ch*.tex pdf文件> ch*.pdf打印的PDF文件。 ,在编译过程中将每个乳胶文件输入到每个ch*.tex中,这些文件被保存到其各自的ch*/目录中。使用makefile,我希望我的ch*.pdf文件由ch*.tex文件编译,并在ch* subdirectory中使用TEX文件。作为其他依赖关系,无需硬编码每个ch*实例。

但是,在某些情况下,可能不存在ch*子目录。随着我的乳胶项目的发展而发生的变化,因为某些ch*.tex文件可以分为子文件,而其他文件可能只是代码的一个大块文件。因此,我希望我的makefile能够使用ch*子目录文件作为依赖项,如果它们不存在,但不是不存在。以下是一些失败的试验:

%.pdf : %.tex %/*.tex
  pdflatex $<

该试验成功地检测了ch*子目录中的现有文件,但是如果没有ch*目录,则无法编译。

%.pdf : %.tex $(wildcard %/*.tex)
  pdflatex $<

该试验无法识别$(WIRDCARD%/*。TEX)作为依赖项,仅使用ch*.tex

如何在ch*子目录(不使用其他子目录中的文件)中使用文件作为其各自的ch*.pdf编译的依赖项?

I have a few PDFLaTeX main files called ch*.tex with numbers replacing the asterick, a PDF file printed by compiling ch*.tex called ch*.pdf, and several LaTeX files input into each ch*.tex during compile that are saved into their respective ch*/ directories. With a Makefile I want my ch*.pdf files to be compiled by ch*.tex files, with TeX files in the ch* subdirectory as additional dependencies, without hardcoding each ch* instances.

However, in some cases the ch* subdirectory may not exist. This changes as my LaTeX projects develops, as some ch*.tex files may be split into subfiles while others may just be one big block file of code. So I want my Makefile to use ch* subdirectory files as dependencies if they exist, but not if they don't. Here are some failed trials:

%.pdf : %.tex %/*.tex
  pdflatex 
lt;

This trial successfully detects existing files in the ch* subdirectory, but fails to compile if there is no ch* directory at all.

%.pdf : %.tex $(wildcard %/*.tex)
  pdflatex 
lt;

This trial doesn't recognise $(wildcard %/*.tex) as a dependency and only uses ch*.tex.

How can I use files in the ch* subdirectory (without using files in other subdirectories) as dependencies for its respective ch*.pdf compilation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

携君以终年 2025-02-13 00:45:23

一种方法是使用

.SECONDEXPANSION:

%.pdf : %.tex $(wildcard $*/*.tex)
        pdflatex 
lt;

One way to do it is to use secondary expansion:

.SECONDEXPANSION:

%.pdf : %.tex $(wildcard $*/*.tex)
        pdflatex 
lt;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文