First commit of new Latex macros.
This commit is contained in:
commit
bcfa5b1f31
|
@ -4,24 +4,152 @@
|
||||||
\usepackage{amsfonts}
|
\usepackage{amsfonts}
|
||||||
\usepackage{amssymb}
|
\usepackage{amssymb}
|
||||||
\usepackage{graphicx}
|
\usepackage{graphicx}
|
||||||
|
\usepackage{color}
|
||||||
\usepackage{ucs}
|
\usepackage{ucs}
|
||||||
\usepackage[utf8x]{inputenc}
|
\usepackage[utf8x]{inputenc}
|
||||||
\usepackage{hyperref}
|
\usepackage{hyperref}
|
||||||
|
|
||||||
%----Macros----------
|
%----Macros----------
|
||||||
\newcommand{\gt}{>}
|
|
||||||
\newcommand{\lt}{<}
|
% Because of conflicts, \space and \mathop are converted to
|
||||||
|
% \itexspace and \operatorname during preprocessing.
|
||||||
|
% \over is simply unsupported.
|
||||||
|
|
||||||
|
% \tensor and \multiscript
|
||||||
|
\makeatletter
|
||||||
|
\newif\if@sup
|
||||||
|
\newtoks\@sups
|
||||||
|
\def\append@sup#1{\edef\act{\noexpand\@sups={\the\@sups #1}}\act}%
|
||||||
|
\def\reset@sup{\@supfalse\@sups={}}%
|
||||||
|
\def\mk@scripts#1#2{\if #2/ \if@sup ^{\the\@sups}\fi \else%
|
||||||
|
\ifx #1_ \if@sup ^{\the\@sups}\reset@sup \fi {}_{#2}%
|
||||||
|
\else \append@sup#2 \@suptrue \fi%
|
||||||
|
\expandafter\mk@scripts\fi}
|
||||||
|
\def\tensor#1#2{\reset@sup#1\mk@scripts#2_/}
|
||||||
|
\def\multiscripts#1#2#3{\reset@sup{}\mk@scripts#1_/#2%
|
||||||
|
\reset@sup\mk@scripts#3_/}
|
||||||
|
\makeatother
|
||||||
|
|
||||||
|
% \slash
|
||||||
|
\makeatletter
|
||||||
|
\newbox\slashbox \setbox\slashbox=\hbox{$/$}
|
||||||
|
\def\itex@pslash#1{\setbox\@tempboxa=\hbox{$#1$}
|
||||||
|
\@tempdima=0.5\wd\slashbox \advance\@tempdima 0.5\wd\@tempboxa
|
||||||
|
\copy\slashbox \kern-\@tempdima \box\@tempboxa}
|
||||||
|
\def\slash{\protect\itex@pslash}
|
||||||
|
\makeatother
|
||||||
|
|
||||||
|
% Renames \sqrt as \oldsqrt and redefine root to result in \sqrt[#1]{#2}
|
||||||
|
\let\oldroot\root
|
||||||
|
\def\root#1#2{\oldroot #1 \of{#2}}
|
||||||
|
|
||||||
|
% Manually declare the txfonts symbolsC font
|
||||||
|
\DeclareSymbolFont{symbolsC}{U}{txsyc}{m}{n}
|
||||||
|
\SetSymbolFont{symbolsC}{bold}{U}{txsyc}{bx}{n}
|
||||||
|
\DeclareFontSubstitution{U}{txsyc}{m}{n}
|
||||||
|
|
||||||
|
% Declare specific arrows from txfonts without loading the full package
|
||||||
|
\makeatletter
|
||||||
|
\def\re@DeclareMathSymbol#1#2#3#4{%
|
||||||
|
\let#1=\undefined
|
||||||
|
\DeclareMathSymbol{#1}{#2}{#3}{#4}}
|
||||||
|
\re@DeclareMathSymbol{\neArrow}{\mathrel}{symbolsC}{116}
|
||||||
|
\re@DeclareMathSymbol{\neArr}{\mathrel}{symbolsC}{116}
|
||||||
|
\re@DeclareMathSymbol{\seArrow}{\mathrel}{symbolsC}{117}
|
||||||
|
\re@DeclareMathSymbol{\seArr}{\mathrel}{symbolsC}{117}
|
||||||
|
\re@DeclareMathSymbol{\nwArrow}{\mathrel}{symbolsC}{118}
|
||||||
|
\re@DeclareMathSymbol{\nwArr}{\mathrel}{symbolsC}{118}
|
||||||
|
\re@DeclareMathSymbol{\swArrow}{\mathrel}{symbolsC}{119}
|
||||||
|
\re@DeclareMathSymbol{\swArr}{\mathrel}{symbolsC}{119}
|
||||||
|
\makeatother
|
||||||
|
|
||||||
|
% Widecheck
|
||||||
|
\makeatletter
|
||||||
|
\DeclareRobustCommand\widecheck[1]{{\mathpalette\@widecheck{#1}}}
|
||||||
|
\def\@widecheck#1#2{%
|
||||||
|
\setbox\z@\hbox{\m@th$#1#2$}%
|
||||||
|
\setbox\tw@\hbox{\m@th$#1%
|
||||||
|
\widehat{%
|
||||||
|
\vrule\@width\z@\@height\ht\z@
|
||||||
|
\vrule\@height\z@\@width\wd\z@}$}%
|
||||||
|
\dp\tw@-\ht\z@
|
||||||
|
\@tempdima\ht\z@ \advance\@tempdima2\ht\tw@ \divide\@tempdima\thr@@
|
||||||
|
\setbox\tw@\hbox{%
|
||||||
|
\raise\@tempdima\hbox{\scalebox{1}[-1]{\lower\@tempdima\box
|
||||||
|
\tw@}}}%
|
||||||
|
{\ooalign{\box\tw@ \cr \box\z@}}}
|
||||||
|
\makeatother
|
||||||
|
|
||||||
|
% udots (taken from yhmath)
|
||||||
|
\makeatletter
|
||||||
|
\def\udots{\mathinner{\mkern2mu\raise\p@\hbox{.}
|
||||||
|
\mkern2mu\raise4\p@\hbox{.}\mkern1mu
|
||||||
|
\raise7\p@\vbox{\kern7\p@\hbox{.}}\mkern1mu}}
|
||||||
|
\makeatother
|
||||||
|
|
||||||
|
%% Renaming existing commands
|
||||||
|
\newcommand{\underoverset}[3]{\underset{#1}{\overset{#2}{#3}}}
|
||||||
|
\newcommand{\widevec}{\overrightarrow}
|
||||||
\newcommand{\darr}{\downarrow}
|
\newcommand{\darr}{\downarrow}
|
||||||
\newcommand{\nearr}{\nearrow}
|
\newcommand{\nearr}{\nearrow}
|
||||||
\newcommand{\nwarr}{\nwarrow}
|
\newcommand{\nwarr}{\nwarrow}
|
||||||
\newcommand{\searr}{\searrow}
|
\newcommand{\searr}{\searrow}
|
||||||
\newcommand{\swarr}{\swarrow}
|
\newcommand{\swarr}{\swarrow}
|
||||||
\newcommand{\iff}{\Longleftrightarrow}
|
\newcommand{\curvearrowbotright}{\curvearrowright}
|
||||||
\newcommand{\impliedby}{\Leftarrow}
|
\newcommand{\uparr}{\uparrow}
|
||||||
|
\newcommand{\downuparrow}{\updownarrow}
|
||||||
|
\newcommand{\duparr}{\updownarrow}
|
||||||
|
\newcommand{\updarr}{\updownarrow}
|
||||||
|
\newcommand{\gt}{>}
|
||||||
|
\newcommand{\lt}{<}
|
||||||
\newcommand{\map}{\mapsto}
|
\newcommand{\map}{\mapsto}
|
||||||
\newcommand{\embedsin}{\hookrightarrow}
|
\newcommand{\embedsin}{\hookrightarrow}
|
||||||
\newcommand{\implies}{\Rightarrow}
|
\newcommand{\Alpha}{A}
|
||||||
|
\newcommand{\Beta}{B}
|
||||||
|
\newcommand{\Zeta}{Z}
|
||||||
|
\newcommand{\Eta}{H}
|
||||||
|
\newcommand{\Iota}{I}
|
||||||
|
\newcommand{\Kappa}{K}
|
||||||
|
\newcommand{\Mu}{M}
|
||||||
|
\newcommand{\Nu}{N}
|
||||||
|
\newcommand{\Rho}{P}
|
||||||
|
\newcommand{\Tau}{T}
|
||||||
|
\newcommand{\Upsi}{\Upsilon}
|
||||||
|
\newcommand{\omicron}{o}
|
||||||
|
\newcommand{\lang}{\langle}
|
||||||
|
\newcommand{\rang}{\rangle}
|
||||||
|
\newcommand{\Union}{\bigcup}
|
||||||
|
\newcommand{\Intersection}{\bigcap}
|
||||||
|
\newcommand{\Oplus}{\bigoplus}
|
||||||
|
\newcommand{\Otimes}{\bigotimes}
|
||||||
|
\newcommand{\Wedge}{\bigwedge}
|
||||||
|
\newcommand{\Vee}{\bigvee}
|
||||||
|
\newcommand{\coproduct}{\coprod}
|
||||||
|
\newcommand{\product}{\prod}
|
||||||
|
\newcommand{\closure}{\overline}
|
||||||
|
\newcommand{\integral}{\int}
|
||||||
|
\newcommand{\doubleintegral}{\iint}
|
||||||
|
\newcommand{\tripleintegral}{\iiint}
|
||||||
|
\newcommand{\quadrupleintegral}{\iiiint}
|
||||||
|
\newcommand{\conint}{\oint}
|
||||||
|
\newcommand{\contourintegral}{\oint}
|
||||||
\newcommand{\qed}{\blacksquare}
|
\newcommand{\qed}{\blacksquare}
|
||||||
|
\newcommand{\infinity}{\infty}
|
||||||
|
\renewcommand{\empty}{\emptyset}
|
||||||
|
\newcommand{\bottom}{\bot}
|
||||||
|
\newcommand{\minusb}{\boxminus}
|
||||||
|
\newcommand{\plusb}{\boxplus}
|
||||||
|
\newcommand{\timesb}{\boxtimes}
|
||||||
|
\newcommand{\intersection}{\cap}
|
||||||
|
\newcommand{\union}{\cup}
|
||||||
|
\newcommand{\Del}{\nabla}
|
||||||
|
\newcommand{\odash}{\circleddash}
|
||||||
|
\newcommand{\negspace}{\!}
|
||||||
|
\newcommand{\widebar}{\overline}
|
||||||
|
\newcommand{\textsize}{\normalsize}
|
||||||
|
\renewcommand{\scriptsize}{\scriptstyle}
|
||||||
|
\newcommand{\scriptscriptsize}{\scriptscriptstyle}
|
||||||
|
\newcommand{\mathfr}{\mathfrak}
|
||||||
|
|
||||||
%-------------------------------------------------------------------
|
%-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ module ActionController
|
||||||
controller.response.headers['Cache-Control'] == 'no-cache'
|
controller.response.headers['Cache-Control'] == 'no-cache'
|
||||||
controller.response.headers['Cache-Control'] = "max-age=#{controller.response.time_to_live}"
|
controller.response.headers['Cache-Control'] = "max-age=#{controller.response.time_to_live}"
|
||||||
end
|
end
|
||||||
controller.response.headers['Etag'] = %{"#{MD5.new(controller.response.body).to_s}"}
|
controller.response.headers['ETag'] = %{"#{MD5.new(controller.response.body).to_s}"}
|
||||||
controller.response.headers['Last-Modified'] ||= Time.now.httpdate
|
controller.response.headers['Last-Modified'] ||= Time.now.httpdate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -148,13 +148,13 @@ module ActionController
|
||||||
|
|
||||||
def send_not_modified(controller)
|
def send_not_modified(controller)
|
||||||
controller.logger.info "Send Not Modified"
|
controller.logger.info "Send Not Modified"
|
||||||
controller.response.headers['Etag'] = %{"#{MD5.new(fragment_body(controller)).to_s}"}
|
controller.response.headers['ETag'] = %{"#{MD5.new(fragment_body(controller)).to_s}"}
|
||||||
controller.render(:text => "", :status => 304)
|
controller.render(:text => "", :status => 304)
|
||||||
end
|
end
|
||||||
|
|
||||||
def client_has_latest?(cache_entry, controller)
|
def client_has_latest?(cache_entry, controller)
|
||||||
requestEtag = controller.request.env['HTTP_IF_NONE_MATCH'] rescue nil
|
requestEtag = controller.request.env['HTTP_IF_NONE_MATCH'] rescue nil
|
||||||
responseEtag = cache_entry.headers['Etag'] rescue nil
|
responseEtag = cache_entry.headers['ETag'] rescue nil
|
||||||
return true if (requestEtag and responseEtag and requestEtag == responseEtag)
|
return true if (requestEtag and responseEtag and requestEtag == responseEtag)
|
||||||
requestTime = Time.rfc2822(controller.request.env["HTTP_IF_MODIFIED_SINCE"]) rescue nil
|
requestTime = Time.rfc2822(controller.request.env["HTTP_IF_MODIFIED_SINCE"]) rescue nil
|
||||||
responseTime = Time.rfc2822(cache_entry.headers['Last-Modified']) rescue nil
|
responseTime = Time.rfc2822(cache_entry.headers['Last-Modified']) rescue nil
|
||||||
|
|
12
vendor/plugins/maruku/lib/maruku/ext/math/latex_fix.rb
vendored
Normal file
12
vendor/plugins/maruku/lib/maruku/ext/math/latex_fix.rb
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
class String
|
||||||
|
|
||||||
|
# fix some LaTeX command-name clashes
|
||||||
|
def fix_latex
|
||||||
|
if #{html_math_engine} == 'itex2mml'
|
||||||
|
s = self.gsub("\\mathop{", "\\operatorname{")
|
||||||
|
s.gsub("\\space{", "\\itexspace{")
|
||||||
|
else
|
||||||
|
self
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,16 +1,17 @@
|
||||||
|
|
||||||
module MaRuKu; module Out; module Latex
|
module MaRuKu; module Out; module Latex
|
||||||
|
|
||||||
|
require 'maruku/ext/math/latex_fix'
|
||||||
|
|
||||||
def to_latex_inline_math
|
def to_latex_inline_math
|
||||||
"$#{self.math.strip}$"
|
s = "$#{self.math.strip}$".fix_latex
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_latex_equation
|
def to_latex_equation
|
||||||
if self.label
|
if self.label
|
||||||
l = "\\label{#{self.label}}"
|
l = "\\label{#{self.label}}"
|
||||||
"\\begin{equation}\n#{self.math.strip}\n#{l}\\end{equation}\n"
|
"\\begin{equation}\n#{self.math.strip}\n#{l}\\end{equation}\n".fix_latex
|
||||||
else
|
else
|
||||||
"\\begin{displaymath}\n#{self.math.strip}\n\\end{displaymath}\n"
|
"\\begin{displaymath}\n#{self.math.strip}\n\\end{displaymath}\n".fix_latex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue