James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.72k stars 533 forks source link

Proposal - context menu, templates #218

Closed kookma closed 6 years ago

kookma commented 7 years ago

context menu (local menu)

It may be helpful, if we have essential commands in context menu (right click inside .tex editor) these are:

Template

Would be great if templates supported

James-Yu commented 7 years ago

Sorry to let you down, but context menu in VSC is currently static, i.e., cannot respond to extension variable changes. At least afaik. I will double check later.

For the template, do you mean by snippets?

kookma commented 7 years ago

Snippets could be a way to implement template. But by template I mean one can open a a .tex file with minimal layout and content for:

TiemenSch commented 6 years ago

In my experience, after some time with LaTeX, almost everyone ends up with different project setups and default packages they like or even dislike using.

Snippets

Snippets should really be your go-to for chunks of code you like to re-use, but want to be able to customize. When using snippets, you will probably want to disable the intellisense surroundcommand helper in settings for this extension.

Since snippets are so powerful though, all you would have to type to instantiate "your" preferred "book" style with default contents would be "mybook">[press enter] and add some folders.

Custom package

Also, you could setup your own commands in a custom package. This basically means just creating a myarticle.sty in your workspace with:

\usepackage[english]{babel} 
\usepackage{amsmath}
% and so on

% my custom symbols for this type of doc
\newcommand{\density}{\mathbb{\rho}}

As long as the .sty's are in your working directory or perhaps a root folder you add to your TeX distribution, you can just import them! \usepackage works in most cases, the only difference is that \RequirePackage can be loaded before the documentclass. Adding a mysymbols.sty is very useful for most scientific documents as you can create commands for your symbols, thus changing them throughout is you change them there.

Template dirs

You could also setup some custom project template dirs for yourself, or create some minimalistic .sty files yourself. Sounds trivial perhaps, but the only difference with all this programming work is a little menu inside VS Code versus copy paste.

Classes

If you really use some setups a lot, you could try and create your own documentclasses in an extra "root folder" for your TeX distribution. That way, you don't have to copy anything into your workspaces, except when sharing with others.

Options

A possible benefit of a template would be a wizard with options. If you dig into setting up a package/documentclass, you'll see you can add in options there as well when you load it in your main tex file. E.g. passing the title, author, image folder etc. there. Although in a snippet fashion, you could define some "commands" in your pre-amble that are re-used throughout as if they were options.