Sublime Forum

Build-Command for latexmk and glossaries

#1

Hi,

first I have to admit, that Sublime is the best software I’ve seen in a while. :smile:

After studying several tutorials I tried to adjust my Sublime for my preferences, e.g. Latex.
Without doing anything it worked quite good for me. Only one problem i ran into.

For my thesis I was using the glossaries package, which isn’t supported with the default build command (latexmk).
After a little research I found some code-snippet how to edit the latexmk command to run with the glossaries package. My problem is, that I don’t know how to edit the build command in a proper way. I have to admit, that I’m not familiar with json.

Here is the code snippet, how the default build-command (json) looks like:

{
	"folders":
	
		{
			"path": "/Users/.../Thesis",
		}
   	],
    "settings":
    	{
       		"tab_size": 4
   		},
   	"build_systems":
   	
       	{
        	"name": "Latex with Glossaries",
	   		"cmd": "latexmk", "-cd", "-e",
	   		"\\$pdflatex = 'pdflatex %O -interaction=nonstopmode -synctex=1 %S}",
			//"-silent",
			"-f", "-pdf"]
    	}
    ]
}

The line with “$pdflatex %0…-synctex=1 %S” is the code which latexmk executes.

To run it with the glossaries-package I found this code, written as a Latexmkrc-file (I think it is Perl :S), which is a file containing the code for Latexmk. At the beginning you can see the pdflatex command, then some additional things and at the end there you will find the part which is important for the glossaries-package.

[code]# Use xelatex instead of pdflatex
$pdflatex = ‘xelatex -synctex=1 -interaction=nonstopmode --shell-escape %O %S’;

Always create PDFs

$pdf_mode = 1;

Use Skim.app to preview generated PDFs

$pdf_previewer = ‘open -a Skim.app %S’;

Use continous mode by default

#$preview_continuous_mode = 1;

output to the directory called output in the current directory

#$out_dir = ‘./output’;

file extensions to remove when cleaning

$clean_ext = ‘acn acr alg aux bbl bcf blg brf fdb_latexmk glg glo gls idx ilg ind ist lof log lot out run.xml toc dvi’;

make latexmk run makeglossaries automatically

add_cus_dep(‘glo’, ‘gls’, 0, ‘makeglossaries’);
add_cus_dep(‘acn’, ‘acr’, 0, ‘makeglossaries’);

sub makeglossaries {
system “makeglossaries $[0]";
if ( -z "$
[0].glo” ) {
open GLS, “>$_[0].gls”;
close GLS;
}
return 0;
}[/code]

I hope somebody, which is more familiar with coding, can help me.

Best regards

SunBob

EDIT: Could an admin please shift this thread to the technical discussion forum? thx

0 Likes

#2

What I did was put that perl script in your home dir:
~/.latexmkrc

Then in the following file :
~/.config/sublime-text-3/Packages/User/LaTeXTools.sublime-settings

You add the following three lines to the builder_settings hash:

	"command" : "latexmk", "-cd", "-e", "$pdflatex = '%E -interaction=nonstopmode -synctex=1 %S %O'", "-f", "-pdf"],
	"command" : "makeglossaries", "main"],
	"command" : "latexmk", "-cd", "-e", "$pdflatex = '%E -interaction=nonstopmode -synctex=1 %S %O'", "-f", "-pdf"],

That should do the trick

0 Likes