Coder Social home page Coder Social logo

yaozhuwa / obsidian-latex-suite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from artisticat1/obsidian-latex-suite

0.0 0.0 0.0 18.35 MB

Make typesetting LaTeX as fast as handwriting through snippets and text expansion

License: MIT License

JavaScript 1.15% TypeScript 95.29% CSS 3.56%

obsidian-latex-suite's Introduction

Obsidian Latex Suite

A plugin for Obsidian that aims to make typesetting LaTeX math as fast as handwriting.

Inspired by Gilles Castel's setup using UltiSnips.

demo

The plugin's main feature is snippets, which help you write LaTeX quicker through shortcuts and text expansion! For example, type

  • "sqx" instead of "\sqrt{x}"
  • "a/b" instead of "\frac{a}{b}"
  • "par x y " instead of "\frac{\partial x}{\partial y}"

See Gilles Castel's writeup for more information.

The plugin comes with a set of default snippets, loosely based on Gilles Castel's. You can modify them, remove them, and write your own.

Usage

To get started, type "dm" to enter display math mode. Try typing the following:

  • "xsr" → "x^{2}".

  • "x/y Tab" → "\frac{x}{y}".

  • "sin @t" → "\sin \theta".

Have a look at the cheatsheet for a list of commonly used default snippets.

Once these feel familiar, you can check out the default snippets for more commands. e.g.

  • "par Tab f Tab x Tab" → "\frac{\partial f}{\partial x}".

  • "dint Tab 2pi Tab sin @t Tab @t Tab" → "\int_{0}^{2\pi} \sin \theta \, d\theta".

You can also add your own snippets! See here for more info on writing snippets. You can view snippets written by others and share your own snippets here.

Features

Auto-fraction

Lets you type "1/x" instead of "\frac{1}{x}".

For example, it makes the following expansions:

  • x/\frac{x}{}
  • (a + b(c + d))/\frac{a + b(c + d)}{}

and moves the cursor inside the brackets.

Once done typing the denominator, press Tab to exit the fraction.

auto-fraction

Matrix shortcuts

While inside a matrix, array, align, or cases environment,

  • Pressing Tab will insert the "&" symbol
  • Pressing Enter will insert "\\" and move to a new line
  • Pressing Shift + Enter will move to the end of the next line (can be used to exit the matrix)

matrix shortcuts

Conceal

This feature must be enabled in settings!

Make your equations more readable by hiding LaTeX code, instead rendering it in a pretty format.

For example, "\dot{x}^{2} + \dot{y}^{2}" will be displayed as "ẋ² + ẏ²".

To reveal the LaTeX code, move the cursor over it.

conceal demo conceal demo 2

Tabout

  • Pressing Tab while the cursor is at the end of an equation will move the cursor outside the $ symbols.
  • Otherwise, pressing Tab will advance the cursor to the next closing bracket: ), ], }, >, or |.

Preview inline math

When the cursor is inside inline math, a popup window showing the rendered math will be displayed.

Color & highlight matching brackets

  • Matching brackets are rendered in the same color, to help with readability.
  • When the cursor is adjacent to a bracket, that bracket and its pair will be highlighted.
  • When the cursor is inside brackets, the enclosing brackets will be highlighted.

color and highlight matching brackets demo

Visual snippets

Sometimes you want to annotate math, or cancel or cross out terms. Selecting some math with the cursor and typing

  • "U" will surround it with "\underbrace".
  • "C" will surround it with "\cancel".
  • "K" will surround it with "\cancelto".
  • "B" will surround it with "\underset".

visual snippets

Auto-enlarge brackets

When a snippet containing "\sum", "\int" or "\frac" is triggered, any enclosing brackets will be enlarged with "\left" and "\right".

auto-enlarge brackets

Editor commands

  • Box current equation – surround the equation the cursor is currently in with a box.
  • Select current equation – select the equation the cursor is currently in.

Snippets

Snippets are formatted as follows:

{trigger: string, replacement: string, options: string, description?: string, priority?: number}
  • trigger : The text that triggers this snippet.
  • replacement : The text to replace the trigger with.
  • options : See below.
  • description (optional): A description for this snippet.
  • priority (optional): This snippet's priority. Defaults to 0. Snippets with higher priority are run first. Can be negative.

Options

  • m : Math mode. Only run this snippet inside math
  • t : Text mode. Only run this snippet outside math
  • A : Auto. Expand this snippet as soon as the trigger is typed. If omitted, the Tab key must be pressed to expand the snippet
  • r : Regex. The trigger will be treated as a regular expression
  • w : Word boundary. Only run this snippet when the trigger is preceded (and followed by) a word delimiter, such as ., ,, or -.

Insert tabstops for the cursor to jump to by writing "$0", "$1", etc. in the replacement.

For more details on writing snippets, including regex snippets, see the documentation here. You can view snippets written by others and share your own snippets here.

Cheatsheet

Trigger Replacement
mk $ $
dm $$

$$
sr ^{2}
cb ^{3}
rd ^{ }
_ _{ }
sq \sqrt{ }
x/y Tab \frac{x}{y}
// \frac{ }{ }
te Tab \text{ }
x1 x_{1}
x,. \mathbf{x}
x., \mathbf{x}
xdot \dot{x}
xhat \hat{x}
xbar \bar{x}
ee e^{ }

When running a snippet that moves the cursor inside brackets {}, press Tab to exit the brackets.

Greek letters

Trigger Replacement Trigger Replacement
@a \alpha eta \eta
@b \beta mu \mu
@g \gamma nu \nu
@G \Gamma xi \xi
@d \delta Xi \Xi
@D \Delta pi \pi
@e \epsilon Pi \Pi
:e \varepsilon rho \rho
@z \zeta tau \tau
@t \theta phi \phi
@T \Theta Phi \Phi
@k \kappa chi \chi
@l \lambda psi \psi
@L \Lambda Psi \Psi
@s \sigma
@S \Sigma
@o \omega
ome \omega

For greek letters with short names (2-3 characters), just type their name, e.g. "pi" → "\pi"

Contributing

Any contributions and PRs are welcome!

Acknowledgements

Support

If you like this plugin and want to say thanks, you can buy me a coffee here!

Buy Me a Coffee at ko-fi.com

obsidian-latex-suite's People

Contributors

artisticat1 avatar b4rc1 avatar yalieny avatar yaozhuwa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.