tag; finally restart the vscode software That’s it."/> tag; finally restart the vscode software That’s it.">
search
HomeDevelopment ToolsVSCodeWhat to do if vscode latex cannot be previewed

What to do if vscode latex cannot be previewed

vscode latex无法预览怎么办?

在VS Code下实时预览Markdown和LATEX

相关推荐:vscode教程

这几天预习期末考试,打算找个方便的文本编辑器记笔记。刚安装了VS Code,用起来觉得挺顺手的,本身还可以实时预览Markdown,就打算直接用它了。

然而Markdown原生并不支持LATEX,打公式只能用如等html tag凑活将就,费时又费力。去VS Marketplace看了一下儿,发现有一款叫Instant Markdown的插件可以用实时把markdown源文件送到浏览器并render预览效果。虽然原生也不支持LATEX,但是可以改嘛!亲自动手丰衣足食,何乐而不为。

心乐之,果断安装。装完随手打开一个.md文件,发现这个插件已经自动用默认浏览器打开了一个网页,render出效果。自己动手改了改这个插件,加上MathJax Library,就已经可以render出Markdown中的LATEX了。步骤如下:

首先在终端/命令提示符下 cd $HOME/.vscode/extensions/dbankier.vscode-instant-markdown-0.1.0/node_modules/instant-markdown-d 进入 instant-markdown 插件的目录。

打开 index.html,在

标签内添加以下代码:
 <script type="text/x-mathjax-config">
  MathJax.Hub.Config({tex2jax: {inlineMath: [[&#39;$&#39;,&#39;$&#39;], [&#39;\\(&#39;,&#39;\\)&#39;]]}});
  </script>
  <script type="text/javascript" async
    src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML">
  </script>

socket.on(&#39;newContent&#39;, function(newHTML) {
  document.querySelector(".markdown-body").innerHTML = newHTML;

后加入一行

MathJax.Hub.Queue(["Typeset",MathJax.Hub]);

既:

<script>
    var socket = io.connect(&#39;http://localhost:8090/&#39;);
    socket.on(&#39;connect&#39;, function () {
      socket.on(&#39;newContent&#39;, function(newHTML) {
        document.querySelector(".markdown-body").innerHTML = newHTML;
+        MathJax.Hub.Queue([&quot;Typeset&quot;,MathJax.Hub]);
      });
      socket.on(&#39;die&#39;, function(newHTML) {
        window.open(&#39;&#39;, &#39;_self&#39;, &#39;&#39;);
        window.close();
        var firefoxWarning =
        "<h1 id="Oops">Oops!</h1>" +
        "<h3 id="Firefox-nbsp-doesn-t-nbsp-allow-nbsp-windows-nbsp-to-nbsp-self-close">Firefox doesn&#39;t allow windows to self-close.</h3>" +
        "<h3 id="If-nbsp-you-nbsp-want-nbsp-the-nbsp-preview-nbsp-window-nbsp-to-nbsp-close-nbsp-automatically-nbsp-like-nbsp-in-nbsp-other-nbsp-browsers-nbsp-go-nbsp-to-nbsp-about-config-nbsp-and-nbsp-set-nbsp-dom-allow-scripts-to-close-windows-nbsp-to-nbsp-true">If you want the preview window to close automatically like in other browsers, go to about:config and set dom.allow_scripts_to_close_windows to true.</h3>"
        document.body.innerHTML = firefoxWarning;
      });
    });
  </script>

4 . 保存,关闭网页,重启VS Code,万事大吉。

The above is the detailed content of What to do if vscode latex cannot be previewed. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Visual Studio: Code Compilation, Testing, and DeploymentVisual Studio: Code Compilation, Testing, and DeploymentApr 24, 2025 am 12:05 AM

In VisualStudio, the steps for compiling, testing and deploying the code are as follows: 1. Compiling: Use VisualStudio's compiler options to convert source code into executable files, supporting multiple languages ​​such as C#, C and Python. 2. Testing: Use built-in MSTest and NUnit to perform unit testing to improve code quality and reliability. 3. Deployment: Transfer applications from the development environment to the production environment through web deployment, Azure deployment, etc. to ensure security and performance.

Visual Studio: An Introduction to the Integrated Development Environment (IDE)Visual Studio: An Introduction to the Integrated Development Environment (IDE)Apr 23, 2025 am 12:02 AM

VisualStudioisMicrosoft'sflagshipIDE,supportingmultipleprogramminglanguagesandenhancingcodingefficiency.1)ItoffersfeatureslikeIntelliSenseforcodeprediction,multi-tabbedinterfaceforprojectmanagement,andtoolsfordebugging,refactoring,andversioncontrol.2

Visual Studio: Exploring the Free and Paid OfferingsVisual Studio: Exploring the Free and Paid OfferingsApr 22, 2025 am 12:09 AM

The main difference between the free and paid versions of VisualStudio is the richness of features and the service supported. The free version (Community) is suitable for individual developers and small teams, providing basic development tools; the paid version (Professional and Enterprise) provides advanced features such as advanced debugging and team collaboration tools, suitable for large projects and enterprise-level development.

Visual Studio Community Edition: The Free Option ExplainedVisual Studio Community Edition: The Free Option ExplainedApr 21, 2025 am 12:09 AM

VisualStudioCommunityEdition is a free IDE suitable for individual developers, small teams and educational institutions. 1) It provides functions such as code editing, debugging, testing and version control. 2) Based on the Roslyn compiler platform, it supports multiple programming languages ​​and integrates Git and TFVC. 3) Advanced features include unit testing, optimization suggestions include turning off unnecessary extensions and using a lightweight editor.

Visual Studio: Building Applications with EaseVisual Studio: Building Applications with EaseApr 20, 2025 am 12:09 AM

VisualStudio is an integrated development environment (IDE) developed by Microsoft, which supports a variety of programming languages, including C#, C, Python, etc. 1. It provides IntelliSense function to help write code quickly. 2. The debugger allows setting breakpoints, step-by-step code execution, and identifying problems. 3. For beginners, creating a simple console application is a great way to get started. 4. Advanced usage includes the application of design patterns such as project management and dependency injection. 5. Common errors can be solved step by step through debugging tools. 6. Performance optimization and best practices include code optimization, version control, code quality inspection and automated testing.

Visual Studio and VS Code: Understanding Their Key DifferencesVisual Studio and VS Code: Understanding Their Key DifferencesApr 19, 2025 am 12:16 AM

VisualStudio is suitable for large-scale projects and enterprise-level application development, while VSCode is suitable for rapid development and multilingual support. 1. VisualStudio provides a comprehensive IDE environment and supports Microsoft technology stack. 2.VSCode is a lightweight editor that emphasizes flexibility and scalability, and supports cross-platform.

Is Visual Studio Still Free? Understanding the AvailabilityIs Visual Studio Still Free? Understanding the AvailabilityApr 18, 2025 am 12:05 AM

Yes, some versions of VisualStudio are free. Specifically, VisualStudioCommunityEdition is free for individual developers, open source projects, academic research, and small organizations. However, there are also paid versions such as VisualStudioProfessional and Enterprise, suitable for large teams and enterprises, providing additional features.

Using Visual Studio: Developing Software Across PlatformsUsing Visual Studio: Developing Software Across PlatformsApr 17, 2025 am 12:13 AM

Cross-platform development with VisualStudio is feasible, and by supporting frameworks like .NETCore and Xamarin, developers can write code at once and run on multiple operating systems. 1) Create .NETCore projects and use their cross-platform capabilities, 2) Use Xamarin for mobile application development, 3) Use asynchronous programming and code reuse to optimize performance to ensure efficient operation and maintainability of applications.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)