latex_document 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/latex_document +73 -23
- data/lib/latex_document/version.rb +1 -1
- data/templates/md/Makefile.tt +43 -0
- data/templates/md/document.tex.md.tt +12 -0
- data/templates/md/template.pandoc.tt +206 -0
- data/templates/references.bib.tt +10 -0
- data/templates/{Makefile.tt → tex/Makefile.tt} +0 -0
- data/templates/{mydefault.sty.tt → tex/include/mydefault.sty.tt} +0 -0
- data/templates/{document.tex.tt → tex/src/document.tex.tt} +1 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17aab20bc284ccbeaf84f8d44b4c5b1b7745615a
|
4
|
+
data.tar.gz: 6afac59b9210f3d095b1578dc2023b95c951610e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 450b21470a0eb3388a57462a5f9c799fb2ab019a03d7f168b02dd2fa647665ca2442ce1a12f8cae7ea66467ded8698b0724a277e233c0c818ff9aafe33673b4e
|
7
|
+
data.tar.gz: 6aad7c83e4b40618d9cafdc15e063b27a1520caea7524d88b7af538462b2c26621712d3182a7887111bf388b46471f492fb6fcc809c5775c595b2155106171ea
|
data/bin/latex_document
CHANGED
@@ -4,10 +4,13 @@ require 'thor'
|
|
4
4
|
require 'date'
|
5
5
|
|
6
6
|
module LatexDocument
|
7
|
-
class
|
7
|
+
class NewDocument < Thor::Group
|
8
8
|
include Thor::Actions
|
9
9
|
|
10
|
-
|
10
|
+
DEFAULT_AUTHOR = 'TODO: Author'
|
11
|
+
|
12
|
+
argument :name, :desc => 'Name of the new document.'
|
13
|
+
class_option :author, :desc => 'Author of the new document.', :default => DEFAULT_AUTHOR
|
11
14
|
|
12
15
|
def self.source_root
|
13
16
|
File.expand_path('../../', __FILE__)
|
@@ -18,22 +21,10 @@ module LatexDocument
|
|
18
21
|
end
|
19
22
|
|
20
23
|
def fill_root
|
21
|
-
empty_directory file_path('src')
|
22
|
-
empty_directory file_path('include')
|
23
|
-
empty_directory file_path('diagrams')
|
24
24
|
create_file_from_template "Makefile"
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
template("templates/document.tex.tt", file_path("src/#{name}.tex"))
|
29
|
-
template("templates/references.bib.tt", file_path("src/references.bib"))
|
30
|
-
end
|
31
|
-
|
32
|
-
def include
|
33
|
-
template("templates/mydefault.sty.tt", file_path("include/mydefault.sty"))
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
27
|
+
protected
|
37
28
|
|
38
29
|
def title
|
39
30
|
title_string = name.dup
|
@@ -42,15 +33,19 @@ module LatexDocument
|
|
42
33
|
title_string.gsub(/[_\.\s](.)/) { " #{$1.upcase}" } # Snake case
|
43
34
|
end
|
44
35
|
|
36
|
+
def author
|
37
|
+
options[:author]
|
38
|
+
end
|
39
|
+
|
45
40
|
def date
|
46
|
-
Date.today.
|
41
|
+
Date.today.strftime('%B %-d, %Y')
|
47
42
|
end
|
48
43
|
|
49
44
|
def file_path(file_name)
|
50
45
|
File.join name, file_name
|
51
46
|
end
|
52
47
|
|
53
|
-
def
|
48
|
+
def create_file_from_shared_template(file_name)
|
54
49
|
template(
|
55
50
|
"templates/#{file_name}.tt",
|
56
51
|
file_path(file_name)
|
@@ -58,16 +53,71 @@ module LatexDocument
|
|
58
53
|
end
|
59
54
|
end
|
60
55
|
|
56
|
+
class Tex < NewDocument
|
57
|
+
def fill_root
|
58
|
+
super
|
59
|
+
empty_directory file_path('src')
|
60
|
+
empty_directory file_path('include')
|
61
|
+
end
|
62
|
+
|
63
|
+
def src
|
64
|
+
template("templates/tex/src/document.tex.tt", file_path("src/#{name}.tex"))
|
65
|
+
template("templates/references.bib.tt", file_path("src/references.bib"))
|
66
|
+
end
|
67
|
+
|
68
|
+
def include
|
69
|
+
create_file_from_template("include/mydefault.sty")
|
70
|
+
end
|
71
|
+
|
72
|
+
protected
|
73
|
+
|
74
|
+
def create_file_from_template(file_name)
|
75
|
+
template(
|
76
|
+
"templates/tex/#{file_name}.tt",
|
77
|
+
file_path(file_name)
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
class Md < NewDocument
|
84
|
+
def fill_root
|
85
|
+
super
|
86
|
+
template("templates/md/document.tex.md.tt", file_path("#{name}.tex.md"))
|
87
|
+
create_file_from_shared_template 'references.bib'
|
88
|
+
create_file_from_template 'template.pandoc'
|
89
|
+
end
|
90
|
+
|
91
|
+
protected
|
92
|
+
|
93
|
+
def create_file_from_template(file_name)
|
94
|
+
template(
|
95
|
+
"templates/md/#{file_name}.tt",
|
96
|
+
file_path(file_name)
|
97
|
+
)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
61
101
|
class LatexDocument < Thor
|
62
|
-
map '
|
102
|
+
map 't' => :tex
|
103
|
+
|
104
|
+
register(
|
105
|
+
Tex,
|
106
|
+
'tex',
|
107
|
+
"tex NAME [author=AUTHOR]",
|
108
|
+
"Creates a new latex document with name NAME and author AUTHOR, the latter of which defaults to \"#{Tex::DEFAULT_AUTHOR}\"."
|
109
|
+
)
|
110
|
+
tasks["tex"].options = Tex.class_options
|
111
|
+
|
112
|
+
map 'm' => :md
|
63
113
|
|
64
114
|
register(
|
65
|
-
|
66
|
-
'
|
67
|
-
|
68
|
-
"Creates a new latex document NAME"
|
115
|
+
Md,
|
116
|
+
'md',
|
117
|
+
"md NAME [author=AUTHOR]",
|
118
|
+
"Creates a new markdown/latex hybrid document with name NAME and author AUTHOR, the latter of which defaults to \"#{Md::DEFAULT_AUTHOR}]\"."
|
69
119
|
)
|
70
|
-
tasks["
|
120
|
+
tasks["md"].options = Md.class_options
|
71
121
|
end
|
72
122
|
end
|
73
123
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#THIS_DIR := $(CURDIR)/$(dir $(lastword $(MAKEFILE_LIST)))
|
2
|
+
THIS_DIR := ./
|
3
|
+
|
4
|
+
default: pdf
|
5
|
+
|
6
|
+
TARGET_BASE = <%= name %>
|
7
|
+
TARGET := $(TARGET_BASE).pdf
|
8
|
+
SRC_DIR = $(THIS_DIR)
|
9
|
+
TARGET_SRC := $(SRC_DIR)/$(TARGET_BASE).tex.md
|
10
|
+
|
11
|
+
BIB := $(SRC_DIR)/references.bib
|
12
|
+
|
13
|
+
TEMPLATE_DIR = $(THIS_DIR)
|
14
|
+
TEMPLATE = template.pandoc
|
15
|
+
TEMPLATE_SRC := $(TEMPLATE_DIR)/$(TEMPLATE)
|
16
|
+
|
17
|
+
# Default geometry
|
18
|
+
geometry = margin=1cm,landscape
|
19
|
+
|
20
|
+
$(TARGET): $(TEMPLATE_SRC) $(TARGET_SRC) | $(TEMPLATE_DIR)
|
21
|
+
pandoc $(TARGET_SRC) -o $(THIS_DIR)/$(TARGET) --template=$(TEMPLATE_SRC) --biblio $(BIB) --variable geometry:$(geometry)
|
22
|
+
|
23
|
+
pdf: $(TARGET)
|
24
|
+
|
25
|
+
# Constant definition
|
26
|
+
NIL = __NIL__
|
27
|
+
|
28
|
+
# Arguments to the `link` command
|
29
|
+
template := $(NIL)
|
30
|
+
biblio := $(NIL)
|
31
|
+
|
32
|
+
link:
|
33
|
+
if [ $(template) != $(NIL) ] && [ -e $(template) ]; then \
|
34
|
+
rm $(TEMPLATE_SRC) > /dev/null; \
|
35
|
+
ln -s $(template) $(TEMPLATE_SRC); \
|
36
|
+
fi; \
|
37
|
+
if [ $(biblio) != $(NIL) ] && [ -e $(biblio) ]; then \
|
38
|
+
rm $(BIB) > /dev/null; \
|
39
|
+
ln -s $(biblio) $(BIB); \
|
40
|
+
fi;
|
41
|
+
|
42
|
+
clean:
|
43
|
+
-rm $(TARGET)
|
@@ -0,0 +1,206 @@
|
|
1
|
+
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
|
2
|
+
$if(fontfamily)$
|
3
|
+
\usepackage{$fontfamily$}
|
4
|
+
$else$
|
5
|
+
\usepackage{lmodern}
|
6
|
+
$endif$
|
7
|
+
$if(linestretch)$
|
8
|
+
\usepackage{setspace}
|
9
|
+
\setstretch{$linestretch$}
|
10
|
+
$endif$
|
11
|
+
\usepackage{amssymb,amsmath}
|
12
|
+
\usepackage{mathtools} % Better boxes around math
|
13
|
+
\usepackage{ifxetex,ifluatex}
|
14
|
+
\usepackage{fixltx2e} % provides \textsubscript
|
15
|
+
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
|
16
|
+
\usepackage[T1]{fontenc}
|
17
|
+
\usepackage[utf8]{inputenc}
|
18
|
+
$if(euro)$
|
19
|
+
\usepackage{eurosym}
|
20
|
+
$endif$
|
21
|
+
\else % if luatex or xelatex
|
22
|
+
\ifxetex
|
23
|
+
\usepackage{mathspec}
|
24
|
+
\usepackage{xltxtra,xunicode}
|
25
|
+
\else
|
26
|
+
\usepackage{fontspec}
|
27
|
+
\fi
|
28
|
+
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
|
29
|
+
\newcommand{\euro}{€}
|
30
|
+
$if(mainfont)$
|
31
|
+
\setmainfont{$mainfont$}
|
32
|
+
$endif$
|
33
|
+
$if(sansfont)$
|
34
|
+
\setsansfont{$sansfont$}
|
35
|
+
$endif$
|
36
|
+
$if(monofont)$
|
37
|
+
\setmonofont[Mapping=tex-ansi]{$monofont$}
|
38
|
+
$endif$
|
39
|
+
$if(mathfont)$
|
40
|
+
\setmathfont(Digits,Latin,Greek){$mathfont$}
|
41
|
+
$endif$
|
42
|
+
\fi
|
43
|
+
% use upquote if available, for straight quotes in verbatim environments
|
44
|
+
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
|
45
|
+
% use microtype if available
|
46
|
+
\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
|
47
|
+
$if(geometry)$
|
48
|
+
\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
|
49
|
+
$endif$
|
50
|
+
$if(natbib)$
|
51
|
+
\usepackage{natbib}
|
52
|
+
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
|
53
|
+
$endif$
|
54
|
+
$if(biblatex)$
|
55
|
+
\usepackage{biblatex}
|
56
|
+
$if(biblio-files)$
|
57
|
+
\bibliography{$biblio-files$}
|
58
|
+
$endif$
|
59
|
+
$endif$
|
60
|
+
$if(listings)$
|
61
|
+
\usepackage{listings}
|
62
|
+
$endif$
|
63
|
+
$if(lhs)$
|
64
|
+
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
|
65
|
+
$endif$
|
66
|
+
$if(highlighting-macros)$
|
67
|
+
$highlighting-macros$
|
68
|
+
$endif$
|
69
|
+
$if(verbatim-in-note)$
|
70
|
+
\usepackage{fancyvrb}
|
71
|
+
$endif$
|
72
|
+
$if(tables)$
|
73
|
+
\usepackage{longtable,booktabs}
|
74
|
+
$endif$
|
75
|
+
$if(graphics)$
|
76
|
+
\usepackage{graphicx}
|
77
|
+
\makeatletter
|
78
|
+
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
|
79
|
+
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
|
80
|
+
\makeatother
|
81
|
+
% Scale images if necessary, so that they will not overflow the page
|
82
|
+
% margins by default, and it is still possible to overwrite the defaults
|
83
|
+
% using explicit options in \includegraphics[width, height, ...]{}
|
84
|
+
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
|
85
|
+
$endif$
|
86
|
+
\ifxetex
|
87
|
+
\usepackage[setpagesize=false, % page size defined by xetex
|
88
|
+
unicode=false, % unicode breaks when used with xetex
|
89
|
+
xetex]{hyperref}
|
90
|
+
\else
|
91
|
+
\usepackage[unicode=true]{hyperref}
|
92
|
+
\fi
|
93
|
+
\hypersetup{breaklinks=true,
|
94
|
+
bookmarks=true,
|
95
|
+
pdfauthor={$author-meta$},
|
96
|
+
pdftitle={$title-meta$},
|
97
|
+
colorlinks=true,
|
98
|
+
citecolor=$if(citecolor)$$citecolor$$else$blue$endif$,
|
99
|
+
urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,
|
100
|
+
linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,
|
101
|
+
pdfborder={0 0 0}}
|
102
|
+
\urlstyle{same} % don't use monospace font for urls
|
103
|
+
$if(links-as-notes)$
|
104
|
+
% Make links footnotes instead of hotlinks:
|
105
|
+
\renewcommand{\href}[2]{#2\footnote{\url{#1}}}
|
106
|
+
$endif$
|
107
|
+
$if(strikeout)$
|
108
|
+
\usepackage[normalem]{ulem}
|
109
|
+
% avoid problems with \sout in headers with hyperref:
|
110
|
+
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
|
111
|
+
$endif$
|
112
|
+
\setlength{\parindent}{0pt}
|
113
|
+
\setlength{\parskip}{6pt plus 2pt minus 1pt}
|
114
|
+
\setlength{\emergencystretch}{3em} % prevent overfull lines
|
115
|
+
$if(numbersections)$
|
116
|
+
\setcounter{secnumdepth}{5}
|
117
|
+
$else$
|
118
|
+
\setcounter{secnumdepth}{0}
|
119
|
+
$endif$
|
120
|
+
$if(verbatim-in-note)$
|
121
|
+
\VerbatimFootnotes % allows verbatim text in footnotes
|
122
|
+
$endif$
|
123
|
+
$if(lang)$
|
124
|
+
\ifxetex
|
125
|
+
\usepackage{polyglossia}
|
126
|
+
\setmainlanguage{$mainlang$}
|
127
|
+
\else
|
128
|
+
\usepackage[$lang$]{babel}
|
129
|
+
\fi
|
130
|
+
$endif$
|
131
|
+
|
132
|
+
%%% macros
|
133
|
+
\newcommand{\final}{\fbox}
|
134
|
+
\newcommand{\bs}{\boldsymbol}
|
135
|
+
\newcommand{\tr}{\operatorname{tr}}
|
136
|
+
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
|
137
|
+
\newcommand{\set}[1]{\left\{ {#1} \right\}}
|
138
|
+
|
139
|
+
\newcommand{\diag}[1]{\mathop{\bigtriangleup\subex{#1}}\nolimits}
|
140
|
+
\newcommand{\stack}[1]{\operatorname{stack}\subex{#1}}
|
141
|
+
\newcommand{\deriv}[2]{\frac{d #1}{ d #2 }}
|
142
|
+
|
143
|
+
\newcommand{\subex}[1]{\left(#1\right)}
|
144
|
+
%%%%
|
145
|
+
|
146
|
+
$if(title)$
|
147
|
+
\title{$title$}
|
148
|
+
$endif$
|
149
|
+
$if(subtitle)$
|
150
|
+
\subtitle{$subtitle$}
|
151
|
+
$endif$
|
152
|
+
$if(author)$
|
153
|
+
\author{$for(author)$$author$$sep$ \and $endfor$}
|
154
|
+
$endif$
|
155
|
+
$if(date)$
|
156
|
+
\date{$date$}
|
157
|
+
$endif$
|
158
|
+
$for(header-includes)$
|
159
|
+
$header-includes$
|
160
|
+
$endfor$
|
161
|
+
|
162
|
+
\begin{document}
|
163
|
+
$if(title)$
|
164
|
+
\maketitle
|
165
|
+
$endif$
|
166
|
+
$if(abstract)$
|
167
|
+
\begin{abstract}
|
168
|
+
$abstract$
|
169
|
+
\end{abstract}
|
170
|
+
$endif$
|
171
|
+
|
172
|
+
$for(include-before)$
|
173
|
+
$include-before$
|
174
|
+
|
175
|
+
$endfor$
|
176
|
+
$if(toc)$
|
177
|
+
{
|
178
|
+
\hypersetup{linkcolor=black}
|
179
|
+
\setcounter{tocdepth}{$toc-depth$}
|
180
|
+
\tableofcontents
|
181
|
+
}
|
182
|
+
$endif$
|
183
|
+
$body$
|
184
|
+
|
185
|
+
$if(natbib)$
|
186
|
+
$if(biblio-files)$
|
187
|
+
$if(biblio-title)$
|
188
|
+
$if(book-class)$
|
189
|
+
\renewcommand\bibname{$biblio-title$}
|
190
|
+
$else$
|
191
|
+
\renewcommand\refname{$biblio-title$}
|
192
|
+
$endif$
|
193
|
+
$endif$
|
194
|
+
\bibliography{$biblio-files$}
|
195
|
+
|
196
|
+
$endif$
|
197
|
+
$endif$
|
198
|
+
$if(biblatex)$
|
199
|
+
\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
|
200
|
+
|
201
|
+
$endif$
|
202
|
+
$for(include-after)$
|
203
|
+
$include-after$
|
204
|
+
|
205
|
+
$endfor$
|
206
|
+
\end{document}
|
data/templates/references.bib.tt
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
@inproceedings{Lanctot09mccfr,
|
2
|
+
title = {Monte Carlo Sampling for Regret Minimization in Extensive Games},
|
3
|
+
author = {Marc Lanctot and Kevin Waugh and Martin Zinkevich and Michael Bowling},
|
4
|
+
booktitle = {Advances in Neural Information Processing Systems 22},
|
5
|
+
editor = {Y. Bengio and D. Schuurmans and J. Lafferty and C. K. I. Williams and A. Culotta},
|
6
|
+
pages = {1078--1086},
|
7
|
+
year = {2009},
|
8
|
+
AcceptRate = {24\%},
|
9
|
+
AcceptNumbers = {263 of 1105}
|
10
|
+
}
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: latex_document
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Morrill
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -68,10 +68,13 @@ files:
|
|
68
68
|
- latex_document.gemspec
|
69
69
|
- lib/latex_document.rb
|
70
70
|
- lib/latex_document/version.rb
|
71
|
-
- templates/Makefile.tt
|
72
|
-
- templates/document.tex.tt
|
73
|
-
- templates/
|
71
|
+
- templates/md/Makefile.tt
|
72
|
+
- templates/md/document.tex.md.tt
|
73
|
+
- templates/md/template.pandoc.tt
|
74
74
|
- templates/references.bib.tt
|
75
|
+
- templates/tex/Makefile.tt
|
76
|
+
- templates/tex/include/mydefault.sty.tt
|
77
|
+
- templates/tex/src/document.tex.tt
|
75
78
|
homepage: https://github.com/dmorrill10/latex_document
|
76
79
|
licenses:
|
77
80
|
- MIT
|