Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Django-Tex Syntax HighlightingNew to Visual Studio Code? Get it now.
Django-Tex Syntax Highlighting

Django-Tex Syntax Highlighting

bfrangi

|
2,738 installs
| (0) | Free
Syntax Highlighting in Django-Tex Templates
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Django-Tex Syntax Highlighting Extension

Installs Version Open VSX

The Django-Tex Syntax Highlighting extension (vscode-django-tex) is a simple VSCode extension for syntax highlighting in django-tex (.tex) templates. The extension is based on another extension called Django, which does the same for .txt and .html templates, so credits to @batisteo for that.


Installation

You can install this extension directly from the Extension Marketplace in VSCode. You can also launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter:

ext install bfrangi.vscode-django-tex

Features

  • Syntax Highlighting in django-tex (.tex) templates:

    Rest of the example code

    Template code:

    \documentclass{article}
    
    \begin{document}
    
        \begin{center}
    
            \section*{Table for {{date|date}} }
    
            \begin{tabular}{ 
                {% for _ in table.body.rows.0 %}|c{% endfor %}| 
                } 
    
                {# This is a comment #}
                \hline
                % This is another comment
    
                \multicolumn{
                    {{table.headers.first.span}}
                    }{|c|}{ {{table.headers.first.value}} } & 
                \multicolumn{ 
                    {{table.headers.second.span}} 
                    }{c|}{ {{table.headers.second.value}} } \\ 
    
                \hline
    
                \iffalse 
                This is a comment spanning several lines
                \hline \fi
    
                {% for row in table.body.rows %}
                {% for cell in row %}{% if not cell == row.0 %} &
                {% endif %} cell{{cell}} {% endfor %} \\
                {% endfor %}
    
                {% comment %}
                This is another comment spanning several lines
                \hline {% endcomment %}
    
                \hline
    
            \end{tabular}
    
        \end{center}
    
    \end{document}
    

    We could combine the code from the django-tex template with the following function based view to render the LaTeX document:

    from django_tex.shortcuts import render_to_pdf
    from datetime import date
    
    def render_pdf(request):
            table = {
                'headers': { 
                    'first': {
                        'span': 3,
                        'value': 'First Multicol',
                    },
                    'second': {
                        'span': 3,
                        'value': 'Second Multicol',
                    },
                },
                'body': {
                    'rows': [
                        [i for i in range(6)],
                        [i for i in range(6)],
                        [i for i in range(6)],
                        [i for i in range(6)],
                        [i for i in range(6)],
                    ]
                },
            }
            filename = 'filename.pdf'
            template_name = 'path/to/template_name.pdf'
    
            context = {
                'date': date.today(), 
                'table': table, 
            }
    
            return render_to_pdf(
                request, 
                template_name, 
                context, 
                filename,
            )
    

    This would produce:


Release Notes

Unreleased

  • No planned changes

0.0.1 - 2022-07-18

Added

  • Initial working version of the extension by @bfrangi.

More

  • View the extension in the Visual Studio Marketplace using this link.

Enjoy!

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft