ashthespy / Atom-LaTeX

The only LaTeX package you need for typesetting with Atom.
https://atom.io/packages/atom-latex
MIT License
22 stars 9 forks source link

Allow setting root file using settings #212

Closed EnochMakenp closed 4 years ago

EnochMakenp commented 4 years ago

There are a few package around that allow to create project in Atom (I'm using project-manager like 1 million other users :-), and for them it will be interesting to have a way to set the root directory, something like: atom-latex.root : "\path\to\my\rootFile.tex

That will remove the need to have the !TEX pragma in the file headers, and make it much more simple :-) I'm trying to hork something locally, but I'm too new to CoffeeScript to really fathom what to do, maybe an observer is needed ?

Thanks for your work !

ashthespy commented 4 years ago

Have you seen the Readme's Project-based Configuration section? Does that do what you need?

I have in my init.coffee the following snippet to set up my per project .latexcfg

atom.commands.add 'atom-workspace',
  'atom-latex:init': () =>
    Fname = atom.workspace.getActiveTextEditor().getTitle() || 'main.tex'
    Fdir = atom.workspace.project.relativizePath(atom.workspace.getActiveTextEditor().getPath())[0] || atom.workspace.project.getPaths()[0]
    config =
      root: Fname
      toolchain: 'arara %DOC -v'
      latex_ext: [".tikz",".tex"]
    fs = require 'fs'
    fs.writeFile("#{Fdir}/.latexcfg",JSON.stringify(config, null, 4),\ # Indendted JSON
      'utf8', (e) ->
        console.log e if e?
        console.log " .latexcfg created for #{Fname} in #{Fdir}"
        )
ashthespy commented 4 years ago

I had some time to check out atom-project-manager and since it just reads the global config.cson you could simple just customise atom-latex.custom_toolchain directly. So something along the lines of

"atom-latex.custom_toolchain" : "%TEX %ARG \path\to\my\rootFile.tex 
&& %BIB \path\to\my\rootFile && %TEX %ARG %DOC.%EXT && %TEX %ARG \path\to\my\rootFile.tex"

PS: you might have to play around with escaping quotes and the slashes if its expecting JSON..

EnochMakenp commented 4 years ago

Thanks for your help - customizing the toolchain may in fact be a good enough workaround solution !