Scite Latex

lua-users home
wiki

印刷符號引用和自動章節結束

載入此腳本以取得 .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?

命令捷徑

這是個架構,用以將例如 \frac{}{} 對應到一個按鍵組合。抱歉,目前沒有自動化功能,您必須手動在您的 latex.properties 檔案中加入適當的命令項目。
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?

Tab 陣列對應到 Tex 陣列

如果您將表格從例如 Excel / OOo Calc 複製貼上,它就會以 Tab 分隔。請標示這些行並執行此腳本,就會出現 \t 替換為 \t&,且行尾以 \\ 結尾。
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?
RecentChanges · 偏好設定
編輯 · 歷史
最後編輯時間 2006 年 8 月 31 日 下午 8:55(GMT) (diff)