TransWikia.com

Error using Makefile to generate TeX file

TeX - LaTeX Asked on June 8, 2021

I’m trying to create a Makefile that generates my document.

➜  resume git:(main) ✗ cat Makefile 
.PHONY: .

CC = xelatex
CURRENT_DIR = .
RESUME_DIR = ./src
RESUME_SRCS = $(shell find $(RESUME_DIR) -name '*.tex')

resume: $(CURRENT_DIR)/resume.tex $(RESUME_SRCS)
        $(CC) -output-directory=$(CURRENT_DIR) $<

clean:
        rm -rf $(CURRENT_DIR)/*.pdf

However, I keep getting the following error, despite the PDF has been successfully generated:

(./src/education.tex) (./src/extracurricular.tex) [2] (./resume.aux) )
Output written on ./resume.pdf (2 pages).
Transcript written on ./resume.log.
make: *** [Makefile:9: resume] Error 1

Is there something wrong with the Makefile? I have been searching around and can’t find the reasons.

One Answer

I'm guessing that you're missing something in your transcript. Looking at the makefile that you provide and your snippet of code, I'm guessing that what's happening is that you're trying to run xelatex on files in your src directory that aren't top-level LaTeX files which is why you're getting the error. To be honest, I don't know that make is a tool that makes sense for LaTeX—unlike with say C where you're going to compile multiple .c files into .o file and then link those into the final executable, the production of the output of LaTeX is a direct compilation of a single top level file (possibly running multiple times). That said, if you're really wanting to try to use a makefile for your purposes, I would replace the definition of RESUME_SRCS with:

RESUME_SRCS = ./src/resume.tex

and you should get the desired result.

When Make makes sense in a LaTeX flow

The situation where it could make sense to use a tool like Make is when you have programmatically-generated files that form input into a LaTeX document. For example, you might have some pre-processing to generate illustrations. Then, in that instance, the makefile would be able to only regenerate illustrations if the underlying data files change and then run LaTeX.

Answered by Don Hosek on June 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP