I have a rule in my Makefile
like the following:
%: %.tex
echo $@
texify --pdf --synctex=1 --clean $@.tex
Whatever file that is passed, I'd like to prepend an existing file called fm.tex
and append another existing file called bm.tex
, but I would like to keep whatever the existing .tex filename that is the value of $@.tex
so that the PDF generated will have that file name. I'm kind of just starting with creating Makefiles, so any help is greatly appreciated.
I've tried some various unix commands, but not getting what I need.
Instead of coming up with complicate prepend/append solutions, simply use the subfiles
package. This way you can compile the main file or the includes files individually.
There are other similar packages, but the advantage of subfiles is that you don't need to repeat the preamble. The subfiles can use the the preamble from the main file.
Main file main.tex
:
\documentclass{article}
% your packages, e.g.
\usepackage{xcolor}
\usepackage{subfiles}
\begin{document}
test
\subfile{cap1}
\end{document}
One of the chapters cap1.tex
:
\documentclass[main]{subfiles}
% no packages necessary, macros from packages like `\textcolor`
% will still work if they are loaded in the main file
\begin{document}
test \textcolor{red}{text}
\end{document}