He appeared a "fairy" undergraduate!
Math class, full keyboard player to play 1700 notes.
Speed hot pursuit teacher writing on the blackboard, formulas, graphs not a drop.
effect? See below:
Not only comparable textbook publishing, but also be able to annotate, search keywords ......
After he went to Po notes are online, it attracted a lot of onlookers.
Less than a day, related tweets, there were already more than 2,000 praise, Hacker News forum stamped more than 200 buildings.
And even friends commented: "! You are a hero we need."
How did he do it? Secret weapon is: LaTeX + Vim !
The little brother from Europe is very strong Amway Vim text editor, he said:
Write mathematical formulas using LaTeX, I chose Vim editor. It is powerful, versatile, highly scalable. As long as the text-based tasks I use it, write code, edit LaTeX, write markdown is.
Although the entry phase of super steep learning curve, but once you have the basic mode of operation, it will stop.
Let's look at the specific processes he accomplish this feat, the tool Download mentioned in the text, we are attached to the end.
Quick Start Tutorial
We take a look at the little brother of the work environment configuration.
He Vim editor LaTeX scenes, like this:
Left Vim, the right is the pdf reader Zathura, it also has similar shortcuts Vim.
Little brother with the operating system is Ubuntu, use bspwm as the window manager. In Vim, LaTex plugins using vimtex, it has syntax highlighting, catalog views, synchronization objects and other functions.
Then, using vim-plug configuration as follows:
Plug 'lervag/vimtex' let g:tex_flavor='latex' let g:vimtex_view_method='zathura' let g:vimtex_quickfix_mode=0 set conceallevel=1 let g:tex_conceal='abdmg'
The last two lines of control "hidden" feature. Turn on this feature, in addition to the line where your cursor is, inclusion of text in LaTeX code will hide or replace other symbols.
For example, in a motion picture below, the hidden [,], after $, without their interference, the entire document more readable. This feature will also use alternative ∩ \ bigcap, ∈ alternative \ in and so on.
Setup is complete, then went to the whole course of the essence:
Notes with LaTeX, how to write on the blackboard as fast like a teacher?
This is the fragment (snippets) play place.
Fragments
What fragments are?
It is a small fragment of text reusable, triggered by other text.
For example, enter sign, and then press the Tab key, the word will be automatically extended for the period of signature:
Fragments may also be dynamic: today and press the Tab key input, it becomes the current date.
Input box and press Tab, there will be a box, it will automatically become larger as the input text.
Fragments, or even can be nested in another fragment used:
How to create fragments? Use UltiSnips
Plug UltiSnips management segment, little brother is so configured:
Sign on the code fragment below:
snippet sign "Signature" Yours sincerely, Gilles Castel endsnippet
For dynamic segments, you can place the code in between `` in the fragment extended and they will run. The following example is used to format the current date bash: date +% f.
snippet today "Date" `date +%F` endsnippet
You can also block where the p ... use Python, such as the code fragment above box is this!:
snippet box "Box" `! = P snip.rv '┌' + '─' * (len (t [1]) + 2) + '┐'` │ $1 │ `! = P snip.rv '└' + '─' * (len (t [1]) + 2) + '┘'` $0 endsnippet
The Python code block is replaced snip.rv of variable values. In the code block, you can access the current state of the code segment, for example, t [1] comprises a first tab stop, fn is the current file name and the like.
LaTex fragment
Use fragments written in LaTeX, hand-written much faster than pure. In particular, some very complex fragment greatly help you save time, prevent crazy.
Here are some very useful and easy to use fragments:
surroundings
Want to insert an environment, simply enter beg at the beginning of a line. Then type the name of the environment, the name \ end {} command is the same. Press the Tab key, you can place the cursor in the newly created environment.
This fragment codes are as follows:
snippet beg "begin{} / end{}" bA \begin{$1} $0 \end{$1} endsnippet
Wherein, b represents only the beginning of this segment expanded line of code, A stands for Auto Expand, that is to say without pressing the Tab key. Tab stops (Tab stop) - that is, you can press Tab and Shift + Tab to jump to the location - with $ 1, $ 2, ...... to represent, the last with $ 0.
Inline and display math
In the process of mathematical notes in mind, the two most commonly used and segments are mk dm.
They are responsible for starting the mathematical model. For the first fragment "inline Mathematics", second for "displaying Mathematics."
Mathematics segment within the line of code is "intelligent": it knows when to enter a word directly behind the $ symbol, it will automatically add spaces. But if you enter a non-word character, it will not add a space, such as in "" $ p $ -value "situation, it is this:
This fragment codes are as follows:
snippet mk "Math" wA $${1}$`!p if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']: snip.rv = ' ' else: snip.rv = '' `$2 endsnippet
The first end of the row w, means that the segment will expand at a word boundary, e.g., hellomk not expand, but will hello mk.
For displaying mathematical fragments simpler, more convenient; With it, you may never forget the end of the equation with a full stop.
Code:
snippet dm "Math" wA \[ $1 .\] $0 endsnippet
Lowercase and superscript
Another useful section is the index. Able to a1 to a1, the a_12 to a {12}.
Trigger this clip is to use regular expressions. There are two cases will be extended fragments. First, a character you type, followed by a number, such as [A-Za-z] \ d; the other is, and has a rear character followed by two numbers, such as [A-Za-z] \ d \ d .
When you use the regular expression parentheses mounted in a part of the group, such as (\ d \ d), you can use fragments are extended by match.group (i) in Python.
As a standard, may be used td, it becomes ^ {}. However, for square, cube and other common fragments, can be used specialized code fragments, such as sr, cb like.
Renderings:
Code:
snippet sr "^2" iA ^2 endsnippet snippet cb "^3" iA ^3 endsnippet snippet compl "complement" iA ^{c} endsnippet snippet td "superscript" iA ^{$1}$0 endsnippet
fraction
Score is a most convenient to use a fragment, extension of the following form:
/ / → frac {}{} 3 / → frac {3}{} 4 ft ^ 2/4 → frac {pi ^ 2} {} (1 + 2 + 3) / → frac {1 + 2 + 3}{} (1 + (2 + 3) /)→(1 + frac {2 + 3}{}) (1 + (2 + 3)) / → frac {1 + (2 + 3)}{
The first segment of code is very simple:
snippet // "Fraction" iA \\frac{$1}{$2}$0 endsnippet
The second and third example, can use regular expressions to match 3 /, 4ac /, 6pi ^ 2 /, a2 / other expressions.
snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "Fraction" wrA \\frac{`!p snip.rv = match.group(1)`}{$1}$0 endsnippet
Read the top of these, you may find regular expressions difficult. Never mind, here is a very intuitive charts to explain:
In the fourth and fifth example, want to change a process. Use UltiSnips regular expression engine can not be resolved, Python can:
Finally, here to share the clip on scores, according to your choice, to generate a score.
You can select some text, then press the Tab key, continue to enter, then press the Tab key.
Code, using the variable $ {VISUAL} to indicate the selected content.
snippet / "Fraction" iA \\frac{${VISUAL}}{$1}$0 endsnippet
Sympy和Mathematica
There is also a cool but used much of the fragment, is to calculate mathematical expressions using Sympy. For example, input SymPy, and then press Tab, can be extended to sympy | sympy, input sympy 1 + 1 sympy, press Tab, 2 can be extended.
Code fragment:
nippet sympy "sympy block " w sympy $1 sympy$0 endsnippet priority 10000 snippet 'sympy(.*)sympy' "evaluate sympy" wr `!p from sympy import * x, y, z, t = symbols ( 'xyz t') k, m, n = symbols('k m n', integer=True) f, g, h = symbols('f g h', cls=Function) init_printing() snip.rv = eval('latex(' + match.group(1).replace('\\', '') \ .replace('^', '**') \ .replace('{', '(') \ .replace('}', ')') + ')') ` endsnippet
With Mathematica, you can also do something similar:
Code fragment:
priority 1000 snippet math "mathematica block" w math $1 math$0 endsnippet priority 10000 snippet 'math(.*)math' "evaluate mathematica" wr `!p import subprocess code = 'ToString[' + match.group(1) + ', TeXForm]' snip.rv = subprocess.check_output(['wolframscript', '-code', code]) ` endsnippet
Suffix fragment
In addition to the top of these, the suffix fragments are also worth sharing. E.g. phat → hat {p} and zbar → overline {z}. There are similar suffix vector, e.g. v ,. → vec {v} and v., → vec {v}. ., And, the order does not matter, it is possible to press both of them simultaneously.
These fragments can really save time, in the order and the teacher wrote on the blackboard like to remember.
Note, bar and hat prefix can also still be used, as long as they are added to a lower priority on the line.
Code for these fragments are:
priority 10 snippet "bar" "bar" riA \overline{$1}$0 endsnippet priority 100 snippet "([a-zA-Z])bar" "bar" riA \overline{`!p snip.rv=match.group(1)`} endsnippet
priority 10 snippet "hat" "hat" riA \hat{$1}$0 endsnippet priority 100 snippet "([a-zA-Z])hat" "hat" riA \hat{`!p snip.rv=match.group(1)`} endsnippet
snippet "(\\?\w+)(,\.|\.,)" "Vector postfix" riA \vec{`!p snip.rv=match.group(1)`} endsnippet
Other fragment
In addition, there are about 100 brother common fragments (Download attached to the end of the text), are most simple. For example, enter> become \ mapsto, input -!> Become \ to and so on.
fun becomes f: \ R \ to \ R:,> become \ mapsto, -> become \ to, cc becomes \ subset!.
lim becomes \ lim {n \ to \ infty}, sum becomes \ sum {n = 1} ^ {\ infty}, ooo becomes \ infty.
Fragment specific course
In addition to some common fragments, fragments can be set for specific courses. For example, in quantum mechanics this course, some of the fragments may be set on bra / ket symbols.
<a|→\bra{a} <ψ|→\bra{\psi}="" a="">→\ket{a}
| Ψ> → \ ket {\ psi}
→\braket{a}{b}
Code:
snippet "\<(.*?)\|" "bra" riA \bra{`!p snip.rv = match.group(1).replace('q', f'\psi').replace('f', f'\phi')`} endsnippet snippet "\|(.*?)\>" "ket" riA \ket{`!p snip.rv = match.group(1).replace('q', f'\psi').replace('f', f'\phi')`} endsnippet snippet "(.*)\\bra{(.*?)}([^\|]*?)\>" "braket" riA `!p snip.rv = match.group(1)`\braket{`!p snip.rv = match.group(2)`}{`!p snip.rv = match.group(3).replace('q', f'\psi').replace('f', f'\phi')`} endsnippet
Context
In the preparation of these segments we need to consider one thing is that "these fragments will be long and commonly used text conflict?"
For example, in English there are about 72 words containing sr, which means when the input disregard the word, sr ^ 2 will be extended to the emergence of a di ^ 2egard.
The solution to this problem is to add context for the code snippet.
By using Vim syntax highlighting, you can determine whether it should extend UltiSnips fragments, depending on whether you are using a mathematical or text.
global !p texMathZones = ['texMathZone'+x for x in ['A', 'AS', 'B', 'BS', 'C', 'CS', 'D', 'DS', 'E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS', 'J', 'JS', 'K', 'KS', 'L', 'LS', 'DS', 'V', 'W', 'X', 'Y', 'Z']] texIgnoreMathZones = [ 'texMathText'] texMathZoneIds = vim.eval('map('+str(texMathZones)+", 'hlID(v:val)')") texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+", 'hlID(v:val)')") ignore = texIgnoreMathZoneIds[0] def math(): synstackids = vim.eval("synstack(line('.'), col('.') - (col('.')>=2 ? 1 : 0))") try: first = next( i for i in reversed(synstackids) if i in texIgnoreMathZoneIds or i in texMathZoneIds ) return first != ignore except StopIteration: return False endglobal
Now, you can context "math ()" to add only want to expand in the mathematical context fragment.
context "math()" snippet sr "^2" iA ^2 endsnippet
Note that the "mathematical context" is a subtle thing. Sometimes you can use the \ text {...} add some text in a math environment. In this case, you do not need to extend fragment. However, in the following cases: \ [\ text {$ ... $} \], they can be extended. That is why math context of the code a bit complicated. The following illustrates these subtleties movable FIG.
In addition to the some of the fragments, you can choose according to their own needs to add some of your own plug-ins or fragments, to improve their efficiency.
Pen or use a computer?
Pure Hand note of the 1700 math notes, awesome enough to describe a little brother, and science and engineering students called the "hero."
Not everyone agreed with brother practice, powerful high-tech tools will often be questioned in front of tradition.
Some users believe that handwriting impressive than the computer typing, but also to reach proficiency little brother, I am afraid LaTeX and Vim have to practice for several years.
Since the pen is more convenient, why should we be taking notes with a computer? The reason is simple: the word ugly!
If you write down the contents of even their desire to see are not, how to review class notes it? At least down the computer typesetting neat, fun to watch.
Although foreign friends debated, but in the country as long as one condition can be completely rejected this approach: not to bring computers into the classroom.
What do you think of it?
Tools Portal:
Linux and Mac system comes with Vim.
Windows users to install Vim:
https://ftp.nluug.nl/pub/vim/pc/gvim81.exe
Vim plugin management:
https://github.com/junegunn/vim-plug
LaTeX plug-in on Vim:
https://github.com/lervag/vimtex
Tiling window manager:
https://github.com/baskerville/bspwm
Vim fragment management tools:
https://github.com/SirVer/ultisnips
If you are uncomfortable with Vim, as well as Emacs, Atom, VS Code, Sublime, they have LaTeX plugin, there's a text editor for you.
LaTeX common mathematical symbols input method:
https://en.wikibooks.org/wiki/LaTeX/Mathematics
Want more familiar with LaTeX use, you need to learn the system, usually more practice is also essential.