james-yu / latex-workshop Goto Github PK
View Code? Open in Web Editor NEWBoost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
License: MIT License
Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
License: MIT License
Hi,
Windows 10 + TeX Live + LaTeX Workshop [1.1.0] - 2017-03-27
Unlike the older version , this latest one seems not to auto save the document before "Build Latex project", so that no changes can be achieved on the PDF unless I save it myself.
Is this a change of usage, or just a bug?
For writing a long document, multiple files is a good way to construct a tex project. Several famous editors support a tex project with multiple tex files.
sublime latextools
emacs auctex
vim latex-suite
Could you please add this feature to latex-workshop plugin?
Is it possible to implement a better (latex related) error handling?
Not sure if this is best handled separately but since I've done a little work on this figured I would at least document it here in case it's of use.
In case you aren't familiar, Chktex is a LaTeX linter - it performs static analysis on .tex
files and reports numerous warnings for many times of common issues people run into when writing LaTeX.
It was simple enough to setup a task in vscode to run chktex:
{
"version": "0.1.0",
"tasks": [
{
"taskName": "build",
"command": "chktex",
"isShellCommand": true,
"args": ["-q", "-v0", "thesis.tex"],
"showOutput": "never",
"problemMatcher": {
"owner": "chktex",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):(\\d+):(.*)$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
},
"severity": "warning"
}
}
]
}
This parses results that look like this:
fitting/supplementary.tex:592:5:44:Wrong length of dash may have been used.
I then used triggertaskonsave to launch this every time I save a .tex file:
"triggerTaskOnSave.tasks": {
"build": ["**/*.tex"]
},
This setup actually works great and I'm totally happy with it. Saying that it's a little complex to put together for a lot of users, so wrapping this up in an extension would make it a lot more accessable, and make it portable across projects.
I considered making a Chktex extension to do this, but before I did that I wondered if you might be interested in a PR that adds Chktex support to LaTeX Workshop. I'd have to write a lot of the same boilerplate code to find the root tex file for instance, so I could see it making more sense as feature within LaTeX Workshop rather than it's own extension.
Ideally I think chktex linting would be an optional feature, that defaults to being on if they user has chktex installed (can always be disabled/cusomised in settings).
If enabled, chktex would be invoked for the root file on every save in parallel with the build, with results being parsed and shown in the problems window.
chktex is pretty fast, so it may even make sense to run chktex on the current file every time the user takes a short break from typing...again, I would suggest these settings would be customisable.
I took a quick look and I think I could quite easily add the feature by generalising the nice Builder
class you have to maybe have a Linter
variant.
Anyway, before getting into any more of the nitty gritty, how would you feel about such an addition?
I use latex to typeset my math homework and I use \ alot to get new lines but the intellisense pops up after this is typed and then I hit enter which puts the first intellisense option in.
I feel that this should be an exception to the intellisense opening, or it should open after a letter is typed after the backslash.
Is there a problem in my setup or am I experiencing an issue with the plugin? After I write \ref{
I can see the list of labels in all my files that I can reference to. However, if I type \cite{
, I do not see any suggestions other than words written in my current file. I was expecting to see something similar to the suggestions in \ref{
.
My bibliography entries are located in a .bib
file in a subfolder of my project. In my main.tex, I have the following command \bibliography{bibliography/references}
At first, with the default settings, I got this result
Step 1: xelatex "report1"
Step 2: bibtex "report1"
Step 3: xelatex "report1"
Step 4: xelatex "report1"
------------
LaTeX Log Parser Result
[T][undefined:39] Overfull \hbox (1.66997pt too wide) in paragraph at lines 39--40
So I went to the settings and set log level to error (I think the output above is a warning), and then I got this
Step 1: xelatex "report1"
Step 2: bibtex "report1"
Step 3: xelatex "report1"
Step 4: xelatex "report1"
------------
LaTeX Log Parser Result
What matters is that the output panel will still be brought out to the front
Newly introduced toolbar icons are bit blurry:
Could I propose these two icons I made with LaTeX Workshop in mind?
In version 0.2.8, inverse synctex does not work properly. I Investigated a little and found that the following two fixes correct this issue. (Since the suggested changes are very short, I just write them below, rather than making a pull request.)
The processing of the tex file pathname returned by synctex needs a fix. SyncTeX seems to return a full path. Furthermore, it is often of the form "/a/b/./c.tex" instead of "/a/b/c.tex"; this leads VS Code to open another window for the same file. This issue seems to be resolved when line 117 of preview.ts is changed to the following, for instance.
let file = record["input"].replace(/(\r\n|\n|\r)/gm, "");
if (file.charAt(0) != '/')
file = path.join(path.dirname(latex_data.main_document), file);
file = file.replace(/\/.\//gm, "\/");
On OS X, to make Cmd+Click send a message to websocket, line 54 of latex.js needs a fix. The following change, for instance, makes it works on OS X:
if (!e.ctrlKey && !e.metaKey) return;
The above changes were made quickly, and so I guess there will be better solutions. Though, I hope this help to improve LaTeX-Workshop!
Preview in a tab works, but if I click "View PDF in browser tab", I get a missing pdf error:
LaTeX Workshop Log says:
[12:28:32] VIEW command invoked.
[12:28:32] Found root file from active editor: /Users/tblazek/Meine_Papers/performance_modelling_journal/performance_modelling.tex
[12:28:32] Open PDF viewer for /Users/tblazek/Meine_Papers/performance_modelling_journal/performance_modelling.pdf
[12:28:33] Error reading PDF file: /"pdf:/Users/tblazek/Meine_Papers/performance_modelling_journal/performance_modelling.pdf
The open-in-tab works:
[12:31:36] TAB command invoked.
[12:31:36] Found root file from active editor: /Users/tblazek/Meine_Papers/performance_modelling_journal/performance_modelling.tex
[12:31:36] Open PDF tab for /Users/tblazek/Meine_Papers/performance_modelling_journal/performance_modelling.pdf
[12:31:36] Found root file from active editor: /Users/tblazek/Meine_Papers/performance_modelling_journal/performance_modelling.tex
[12:31:36] Preview PDF file: /Users/tblazek/Meine_Papers/performance_modelling_journal/performance_modelling.pdf
LaTeX-Workshop v1.1.1
VS Code v1.10.2
macOS Sierra
The browser error happens both in Chrome and Firefox. Let me know if I can provide you with data.
Hi,
This is no problem at all. But I think it would be a good idea to mention that TeX Live is necessary because of the Synctex binary.
Following #37 I think there is a bit of a broader issue here. I then found autocompletion didn't work, and to get it to work, sure enough I had to change:
- context.subscriptions.push(vscode.languages.registerCompletionItemProvider('LaTeX', extension.completer, '\\', '{', ','));
+ context.subscriptions.push(vscode.languages.registerCompletionItemProvider('latex', extension.completer, '\\', '{', ','));
I took a look at the language selection screen and see this:
I then realised I have the basic LaTeX language support installed:
https://marketplace.visualstudio.com/items?itemName=ms-vscode.latex
And figured that will be making the association from .tex
-> latex
.
Sure enough, if I uninstall it:
LaTeX Workshop gets it's way and chooses LaTeX
as the language ID.
The problem is, I'm sure many other users will have the basic syntax highlighting extension installed as I did, and will run into these kinds of issues. Furthermore, the dev guide for language extensions has this to say on Language IDs:
A language identifier is often (but not always) the lowercased programming language name. Note that casing matters for exact identifier matching ('Markdown' != 'markdown').
It seems to me that it makes a lot more sense for LaTeX Workshop to continue to standardise on lower case latex
for the language ID to match the wider vscode/latex community to avoid all these confusions and issues.
PS hope this doesn't come across really negative, as I think you've done a great job of tidying everything up in this new version! Very happy to continue contributing over the next few months whilst I'm writing my thesis 👍 :)
When I try to reconfigure the plugin in the workspace settings, I find that they are not applied until I close the workspace and open it again. For example, I wanna use xelatex instead of pdflatex, so I put
"latex-workshop.compiler": "xelatex"
in .vscode/settings.json
, but then when I saved the file again, it was still invoking pdflatex
.
It's not something that is quite important, but in the beginning that's a little bit annoying.
And thanks for the impressive plugin 👍 .
The new default option for latex-workshop.toolchain
uses latexmk
as opposed to texify
. Under MiKTeX, however, latexmk
fails unless a separate Perl interpreter is also installed and properly configured by the user. As a possible mitigation, the following seems setting to work under MiKTeX:
"latex-workshop.toolchain": [
"texify --synctex --tex-option=\"-interaction=nonstopmode -file-line-error\" --pdf %DOC%"
]
Currently, the preview do not work well for me. It only covers the left top part in the split window.
Is it due to the high resolution ratio of my laptop?
Linter is always active even when "latex-workshop.linter" is set to false. Also when I change any of the Linter cmds. i.e. adding "-n1" or add kind of flags still shows up that warning.
Regards, José
Hi,
Windows 10 with TeXLive 2016 , it fails to Reverse SyncTex (from PDF to Tex). Any idea?
When opening the main tex file of a project, I get a warning saying "SyncTeX not found", even though there is a file ".synctex.gz" available. The warning is also shown when using synctex without compression ("-synctex=-1"). Building the pdf with pdflatex as well as the pdf preview work. Syncing does not.
I am working on Windows 10 with the MiKTeX distribution.
Could you maybe please make the status bar button "Compile-on-save Enabled" make (optionally) smaller, e.g. without the text that accompanies the switch?
It occupies quite some space, having it reduced would make it less obtrusive, as it persists no mater what file type one is working with.
This is possibly related to:
Preview is just a part of the split window #5
and may actually be more of an upstream issue with the window provided by previewHTML
from the vscode api
Basically the preview window overflows when you globally scale the client smaller (Zoom out) Ctrl
+-
and underflows when globally scaling larger (Zoom in) Ctrl
+=
, the later case looking identical to the issue shown in #5.
If one dynamically resizes the outerContainer
in viewer.html to have the size of the window outer width then this seems to fix in the case of being zoomed out.
<script type="text/javascript">
var hackZoomOutFix = function(){
var screenCssPixelRatio = (window.outerWidth) / window.innerWidth;
/* // for live debugging the window dims as seen from viewer.html
$('#saywidth').text(' (' + window.outerWidth + ') / ' + window.innerWidth + ' ' + screenCssPixelRatio);
*/
if (screenCssPixelRatio < 0.99){
$('#outerContainer').width(window.outerWidth+'px');
}
else{
$('#outerContainer').width('100%');
}
};
$(document).ready(function(e){hackZoomOutFix ;setTimeout(hackZoomOutFix ,1000)});
$( window ).resize(function(e){hackZoomOutFix ;setTimeout(hackZoomOutFix ,1000)})
</script>
However in the case where you are globally zoomed in even trying to resize the window port using window.resizeTo(h,w)
does not seem to be able to stretch the preview pane out to the correct dimensions hence the suspicion that this is an upstream issue?
I hope this is useful
ps
also added: to viewer.html to make use of jquery,
<script src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
this was mainly so that I could add a live print-out of the window dims, this also required adding
<div id="saywidth" style="position: fixed;
top: 34px;
width: 100%;
color: red;"></div>
at the bottom of the body.
Btw LOVE this extension! I had a half baked attempt at integrating pdfjs myself a few months back but never completed the integration due to, ironically, paper deadlines!
Hi,
Since yesterday's update, I can't see commands autocomplete themselves, when I start with a ''. Odd enough, after typing '{}' the menu shows up, but it doesn't help much.
For eg. \sub --> doesn't show \subsection
b{} --> will show begin, if there is no '' before it.
I found that after updating to version 1.1.0 there's no more "Preview" button. I highly rely on this functionality because every time I save my tex file, the PDF in the preview tab will be updated immediately. Really convenient! Without this, unfortunately, I have to right click the file "View PDF" to open the PDF every time I want to see the new change because the viewing tab will not show the updated content automatically.
Will the preview functionality be added back? Thanks!
(I am running Visual Studio Code Version 1.10.2 on macOS 10.12.3)
Seems the bibtex parsing is struggling in the new version, and I don't know if it's simple to gain the robustness back.
I'm looking into it now. It may make more sense to go back to relying on a third party provider to cover weird edge cases in bibtex.
As I move over from ShareLaTeX, I'm wondering if support for autocompletion of environment \begin... \end
's could be implemented? E.g. in ShareLaTeX I can type \ali
, and \begin{align}...\end{align}
appears in the dropdown.
show preview
and wait after compileshow preview
it or save document BHi!
SyncTeX and LaTeX compiler not found if Visual Studio Code is started from macOS dock.
Great extension BTW!
Although the autocomplete which turns one quote into two quotes is correctly disabled inside $...$
and \[...\]
when the delimiters appear on the same line -- as it should be since in math the quote char is used for "prime" -- it is not disabled when the delimiters appear on different lines, or inside standard amsmath environments such as align*
, or inside \ensuremath
, or in \newcommand
content which gets spliced into a math context. More than 50% of my math appears in such places, and so the autocomplete gets in the way more often than it helps. Since detecting such contexts is impractical in general, and autocompleting one quote into two quotes is not much of a help anyway, I would like an option to disable it altogether.
Hi,
after I updated to version 1.4.0 I noticed that syntex stopped working using my key shortcut and also right-click command. Ctrl+leftmouse on the pdf still works.
Regards, José
Sorry to bother you again.
In the latest version , commands autocomplete themselves only when they had already existed, like many other language support extensions. It's acceptable , but I really prefer how previous versions work that commands can be autocompleted since it's been first typed in.
Will it be update in future versions? Or it has been what you mean?
Thank you.
After the February update, I was no long able to see the preview: It is now only an empty column. By switching back the previous version of vs code, I was able to see preview correctly.
I'm doing something using the expl3
syntax these days. Is it possible to add the LaTeX3 syntax support in the future?
Hello, I am not able to use the linting even if:
That's the error I am encountering:
[18:02:56] Linter for active file started.
[18:02:56] Linter for active file running command chktex with arguments -wall,-n22,-n30,-e16,-q,-I0,-f%f:%l:%c:%d:%k:%n:%m
[18:02:56] Linter for active file failed to spawn command, encountering error: spawn chktex ENOENT
Thank you in advance.
An option would be great to store the generated build files like main.aux, main.out, main.toc and so on in a separate directory. All files generated during a build should be redirected to this folder.
This could be possible with this compile_argument:
"-synctex=1 -interaction=nonstopmode -file-line-error -jobname \"Output/Output filename\""
But the problem is now that bibtex is looking for a file with the name main:
Step 1: pdflatex -synctex=1 -interaction=nonstopmode -file-line-error -jobname "Output/Output filename" "main"
Step 2: bibtex "main"
Error: Command failed: bibtex "main"
bibtex "main"
(exited with error code 1)
This atom plugin is able to do it: https://atom.io/packages/latex
Even i install LaTeX distribution in system PATH
D:\Program Files\MiKTeX 2.9\miktex\bin\x64
but i get this
Step 1: xelatex -synctex=1 -interaction=nonstopmode -file-line-error "untitled-1"
Step 2: bibtex "untitled-1"
Error: Command failed: bibtex "untitled-1"
bibtex "untitled-1"
(exited with error code 1)
After upgrade to 0.2.1 extension ceased to to compile.
It was unclear to me it it's not caused by me tweaking the configuration as I have migrated synctex.exe from TeX Live to MiKTeX but it turns out to be an exception in compile.js. It happens in this line:
preview_1.getPreviewPosition();
where exception's message says:
"Cannot read property 'send' of undefined"
If the preview is NOT displayed prior to compilation.
How about making the workflow smarter? I mean, if there is a \bibliography
in the main document, we'll do %compiler%
, bibtex
, %compiler%
, %compiler%
. But if there is not, we can simply do %compiler%
once.
(I know that I can config the workflow in the settings.json
, but it's not convenient.)
Dear James, I apologize for which is maybe a simple question :
I tried to assign a shortcut to use the command synctex like this:
{"key": "alt+numpad2", "command": "latex-workshop.synctex"}
However this has no effect. But using right click "Find here in Preview" works.
Do you know where the problem come from.
Thank you for you last answer. With the last update of code, it is now possible to see the symbol \sum and \prod.
Once again, thank you for your extension.
PS : I am on linux mint.
If I'd rather manually compile my document than use latexmk, what placeholder would I use to refer to my .bib file when running bibtex? If I modify the toolchain to run bibtex main.bib
where I typed in main
by hand, bibtex runs correctly; I just don't know how to have the toolchain automatically find my .bib from project to project.
Hi I just compiled my CV but if I enable Bibtex in the compiling cycle "Xelatex->Biblatex->Xelatex->Xelatex", it went wrong with error code 2. It works fine if I disable it. Is it because there is no such a .bib file?
I have a bibliography-setup that looks like this call:
\bibliography{./latex-base-files/library,./latex-base-files/IEEEabrv,./latex-base-files/settings}
That is one actually library, the Abbreviation rules, and customized settings. I need the keys from file 1.
The parser doesn't work with this, because it take the whole body of the bibliography-command. Due to the way the regex is set up, I can work for now like this
%\bibliography{./latex-base-files/library}
\bibliography{./latex-base-files/library,./latex-base-files/IEEEabrv,./latex-base-files/settings}
This parses the bibliography call in the comment line and finds the citations.
It would be great however if the parser could split the bibliography line by "," symbols and parse them partially. I may try to do this if i find the time, but I don't know Javascript that well.
On MacOS, the PDF Viewer in a tab doesn't fill the whole width of the tab. So, the viewer has a small width discouraging any reading. It was ok before version 1. Except that, your extension is very useful. Thanks for any improvements!
Hi, It would be nice if it was possible to call with forward search an external pdf viewer as okular for instance.
Moreover, forward search is only accessible after a right-click. Is it possible to assign it a shortcut as Ctrl+left-click ?
Hi,
I want to know all your thoughts on this:
Currently, when entering a cite-command, a list of all citationKeys in the bib-files comes up, and typing incrementally searches this. LaTeXing for sublime has a similar feature, however, there, the entries in the list are combined key+title+authors, which means you can search for any part.
I understand that that adds a lot of noise, but it facilitates finding the right citation (at least for me). Any thoughts?
When I have two different tex files open at the same time, saving always compiles the one that I opened first.
Fantastic extension by the way. Once I find a suitable spellcheck solution for it, I will won't have any need for other latex editors.
To avoid issues like #69 (which has affected the user for both compilation and linting) I wonder if we could do some basic detection of where we might be able to find the binaries for pdflatex
/chktex
etc on a users system even if they aren't on their $PATH
...
Hi,
all the symbols obtained by the latex command \sum and \prod do not appear in the previewed pdf.
The large parenthesis are also not display.
By the way, very good extension :) thanks for it.
After I edit the tex and save, the pdf viewer refreshes but shows the first page and default zoom level. It would be nice if it stays on the same page where I was looking at (or maybe shows the page where I edited on tex file) and same zoom level after refresh.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.