ILi*_*les 3 latex makefile pdflatex
我正在尝试使用 makefile 来在 LaTex 中编译我的故事。我正在尝试使用变量来完成我的故事的文件名。如果我只是运行 make,它就可以工作。但是,我需要能够从 make 运行特定命令。
pdflatex "\\def\\isdraft{1} \\input{FMPGC.tex}"
Run Code Online (Sandbox Code Playgroud)
我如何从 PROJ + OBJS 创建一个变量,以便我可以做类似我在下面尝试做的事情。如果我运行下面的代码来制作草稿,它会失败并且看起来它在 FMPGC 和 tex 之间添加了许多空格。
我怎样才能用“.”组合两个变量?这对之间的符号,这样我就可以在下面的命令中编译我的故事。我还尝试过不转义 \ 符号,但这似乎没有效果。
# This makefile compiles my story using LaTex
# Author:
#
# VARS - Variables to be changed for reuse of my script
PROJ = "FMPGC" # The name of the project
OBJS = "tex" # The extension for the content
AUXS = "aux" # The aux extensions
CHAP = "chapters/" # The chapters
FOO = $(PROJ) += "."
F002 = $(FOO) += $(OBJS)
# Configuration:
CC = pdflatex # The compiler
# Rules
all:
$(CC) $(PROJ).$(OBJS)
draft:
$(CC) "\\def\\isdraft{1} \\input{$(FOO2)}"
Run Code Online (Sandbox Code Playgroud)
当前的错误来自于它现在没有向变量输入任何内容 -
pdflatex "\\def\\isdraft{1} \\input{}"
Run Code Online (Sandbox Code Playgroud)
下面似乎是确切的问题。
<*> \def\isdraft{1} F
MPGC.tex
Run Code Online (Sandbox Code Playgroud)
---------------- 更新了 Make 文件
# This makefile compiles my story using LaTex
# Author:
#
# VARS - Variables to be changed for reuse of my script
# The name of the project
PROJ:=FMPGC
# The extension for the content
OBJS:=tex
# The aux extensions
AUXS:=aux
# The chapters
CHAP:=chapters/
# Configuration:
# The compiler
CC=pdflatex
# Rules
all:
$(CC) $(PROJ).$(OBJS);
draft:
$(CC) "\def\isdraft{1} $(PROJ).$(OBJS)";
Run Code Online (Sandbox Code Playgroud)
更新错误----
pdflatex "\def\isdraft{1} FMPGC.tex";
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
LaTeX2e <2014/05/01>
Babel <3.9k> and hyphenation patterns for 21 languages loaded.
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
<*> \def\isdraft{1} F
MPGC.tex
?
! Emergency stop.
...
<*> \def\isdraft{1} F
MPGC.tex
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on texput.log.
Run Code Online (Sandbox Code Playgroud)
在GNU make 手册的变量的两种风格部分中,我们发现:
\n\n\n如果您在变量值的末尾添加空格,最好在行末尾添加类似的注释以明确您的意图。相反,如果您不希望变量值末尾有任何空格字符,则必须记住不要在某些空格后面的行尾添加随机注释,例如:
\nRun Code Online (Sandbox Code Playgroud)\ndir := /foo/bar # directory to put the frobs in\n这里变量 dir 的值为 \xe2\x80\x98/foo/bar \xe2\x80\x99 (带有四个尾随空格),这可能不是本意。(想象一下像 \xe2\x80\x98$(dir)/file\xe2\x80\x99 这样的定义!)
\n