Scite Latex |
|
載入此腳本以取得 .tex 檔案,當您在 \begin{group} 按下 enter 後,它會自動插入 \end{group}。它並不完美,但大部分時候都能為我的 LaTeX 程式碼格式風格運作。它也會用適當的 (德國文) 符號 ("` 和 "') 取代一般英吋符號 (")。
prevquote="'"; nextquote="`"; function ReplaceQuote() at = editor.CurrentPos; editor:insert(at, nextquote); editor:GotoPos(at+1); prevquote, nextquote = nextquote, prevquote; end; function CheckBlock() local m_end = 0; local senv, env; line = editor:LineFromPosition(editor.CurrentPos); str = editor:GetLine(line-1); -- look for last \begin{foo} repeat senv = env; m_start, m_end, env = string.find(str, '\\begin{(.-)}', m_end); until m_start == nil; -- add \end{foo} if(senv) then local pos = editor.CurrentPos; editor:insert(pos, "\\end{"..senv..'}'); end; end; function OnChar(char) if(char=='"') then ReplaceQuote(); elseif(char=="\n") then CheckBlock(); end; end;-- SebastianSteinlechner?
function add_tags(a, b) if(editor:GetSelText() ~= '') then editor:ReplaceSel(a .. editor:GetSelText() .. b); else editor:insert(editor.CurrentPos, a..b); editor:GotoPos(editor.CurrentPos + string.len(a)); end; end function tex_frac() add_tags('\\frac{', '}{}'); end; function tex_up() add_tags('^{', '}'); end; function tex_down() add_tags('_{', '}'); end;-- SebastianSteinlechner?
function tex_makearray() if(editor:GetSelText() == '') then return; end; local mytext = editor:GetSelText(); mytext = string.gsub(mytext, "\t", "\t& "); mytext = string.gsub(mytext, "\n", "\\\\\n"); editor:ReplaceSel(mytext); end;-- SebastianSteinlechner?