solution to compile :

latexmk -pdf mainfile.tex

I have left this example up as it might contain language used by others unfamiliar with this area :)

At the very least it provides a Minimal Working example of compiling a master file which includes a sub file, as well as a bibliography. All these are in the same directory for this example (I'm sure there are more pragmatic solutions to file management, "an exercise to the reader...").

Here is a bash alias that I use as I always have the main file called main.tex

# latex compile if files called main
alias ltmk="latexmk -bibtex -pdf -pvc ./main.tex"

I can't vouch for that being best practice - it works for me though.

I can compile a document using latexmk -pdf

If i have a tex file as a master that includes other tex files latexmk seems to get confused, I'm just wondering what the best practice is here?

I've tried to specify the master file with something like latexmk master.tex -pdf


Here's a MWE (I think!)

Main File


\chapter{Something that I have written }\label{introduction}

This will be a citaion: \parencite{WinNT}
Here is another citation!(with parens) : \parencite{WinNT}
have another go \parencite{WinNT}

% this is the file that I would like to be input at this 
% location




File to be included

\section{Something else}

This is something that's being included. 

Can I still cite things from the bib file that's in the 

Like \parencite{WinNT}

I'm not sure....

Bib file

  author = {MultiMedia LLC},
  title = {{MS Windows NT} Kernel Description},
  year = 1999,
  url = {http://web.archive.org/web/20080207010024/http://www.808multimedia.com/winnt/kernel.htm},
  urldate = {2010-09-30}
  • What about latexmk -pdf master.tex? You need to describe "get's confused" in more detail please :-) – darthbith Mar 17 '15 at 20:44
  • i think you can probably substitute me for latex in that line, I'll try that now – baxx Mar 17 '15 at 20:45
  • @darthbith that seems to be working fine, feeling suitably daft. Unless I hear otherwise I'll delete this post as Its probably not a common problem ;) – baxx Mar 17 '15 at 20:49
  • Happens :-) If you think you can edit the post to be useful, please do so and provide a suitable answer! – darthbith Mar 17 '15 at 21:01
  • @darthbith I'll try without saying 'don't be daft' ;) – baxx Mar 17 '15 at 21:13

The problem here is that if you do not specify any files on latexmk's command line, it will, by default, try to compile all the tex files in the current directory. But if some of the files are input by others instead of being compilable by themselves, there will be errors, as the OP found.

The simplest work-around is, as observed in the question, to put the desired primary filename on the command line.

But it is nevertheless a convenience just to type latexmk and have the program figure out what to do. There are two configuration variables that can change latexmk's default behavior: See the documentation for @default_files and @default_excluded_files. [The second variable was only documented starting in v. 4.43a, which is the current version when I write this answer.]

In the example in the problem, putting the following lines in one of latexmk's configuration rc files will allow the simple command line latexmk to work

@default_excluded_files = ( 'test.tex' );
$pdf_mode = 1; $dvi_mode = $postscript_mode = 0;

As a bonus, I've added the second line so that just pdf files will be made, without the need to include -pdf on the command line, which I find convenient.

  • Is it possible to change latexmk configuration variables (e.g. $aux_dir) inside the command itself?. If yes, can you write down an example of working latexmk command including a definition of, for example, $aux_dir? – Diaa Aug 12 '16 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.