Scite Latex |
|
将此脚本加载到 .tex 文件中,当您在 \begin{group} 后按回车键时,它会自动插入 \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?