Better font handling with memoir
This commit is contained in:
parent
232c0f7b0b
commit
3243e85174
7 changed files with 196 additions and 186 deletions
|
@ -15,6 +15,7 @@
|
|||
# Comment the following line if you haven't
|
||||
# Hoefler Text font installed on your system
|
||||
@latex_headers<<='\setmainfont{Hoefler Text}'
|
||||
# @latex_headers<<='\setmonofont{Monaco}'
|
||||
|
||||
# Use colors
|
||||
@latex_headers<<='\usepackage{color}
|
||||
|
@ -22,7 +23,7 @@
|
|||
\definecolor{boxcolor}{rgb}{0.96,0.96,0.96}'
|
||||
|
||||
# Make italic and emphasis text gray
|
||||
@latex_headers<<='\renewcommand{\textit}[1]{\textcolor{italiccolor}{\it #1}}
|
||||
@latex_headers<<='\renewcommand{\textit}[1]{\textcolor{italiccolor}{\it #1}}
|
||||
\renewcommand{\emph}[1]{\textcolor{italiccolor}{\em #1}}'
|
||||
|
||||
# change the template file in case latex_headers is not enough
|
||||
|
|
|
@ -94,7 +94,7 @@ that the %markdown is more natural than the %latex one.
|
|||
On the other hand Markdown wasn't created for this purpose.
|
||||
Markdown was done to provide a standard syntax to transform some text file into HTML.
|
||||
Markdown lack many features that many other project have added to it.
|
||||
One of this project is [Kramdown]().
|
||||
One of this project is [Kramdown](http://kramdown.rubyforge.org).
|
||||
There is many other project that expanded the abilities of Markdown.
|
||||
|
||||
But I believe not any of these project is scalable because the power of these language is _stricly_ inferior to the power of the %tex_ language.
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
# Install
|
||||
|
||||
If you are reading these lines
|
||||
chances are great that your system contains all necessary packages.
|
||||
But here are the dependencies:
|
||||
|
||||
- ruby,
|
||||
- rake,
|
||||
- %kramdown[^1]
|
||||
|
||||
Optionally you'll need:
|
||||
|
||||
- %latex (more precisely %xelatex) to generate PDF output,
|
||||
- MathJax to draw correctly math formulae inside HTML website,
|
||||
- `pdf2svg` to generate the SVG oriented website.
|
||||
|
||||
[^1]: %kramdown is an amelioration of the original markdown format.
|
||||
|
||||
1. You'll need to install ruby and rake.
|
||||
They should be present on your system.
|
||||
But if you are using Ubuntu the following command line should be enough:
|
||||
|
||||
[Ubuntu]> sudo apt-get install ruby rake
|
||||
|
||||
2. In order to install the %kramdown gem:
|
||||
|
||||
> gem install kramdown
|
||||
|
||||
3. To install %xelatex, I suggest you to use [TexLive](http://www.tug.org/texlive/) full install to be certain not lacking anything.
|
||||
Of course you are free to use any other distribution that suit you better.
|
||||
|
||||
4. Download [MathJax](http://www.mathjax.org)
|
||||
|
||||
5. Finally Download the [source code](http://github.com/yogsototh/krambook) and copy the MathJax directory into `site/js/`.
|
||||
|
||||
Verify if all work correctly by running:
|
||||
|
||||
> rake
|
||||
> rake html
|
||||
|
||||
Congratulation you are ready.
|
||||
|
||||
# First steps
|
||||
|
||||
- Edit the `config.rb` file (set title, author name and pdf filename)
|
||||
- Create and write files in the `content` folder. You should write them using the [kramdown](http://kramdown.rubyforge.org/) format. Very close to the %mardown format.
|
||||
- run `rake` (or `rake compile`) to create and show a `.pdf` file.
|
||||
|
||||
Remark:
|
||||
: by default file are sorted by name. I suggest you to name your files and folder with number prefixes. For example like `00_intro.md`, `01_section/01_subsection.md`, etc... You can make a bit of `ruby` (search `@filelist` in the `Rakefile` file) to change this behaviour.
|
||||
|
||||
Of course there is also a
|
||||
|
||||
rake clean
|
||||
|
||||
and
|
||||
|
||||
rake clobber
|
||||
|
||||
# Macros
|
||||
|
||||
Now you can write the content of your book mostly in %kramdown format.
|
||||
But with some simple additions: _macros_.
|
||||
|
||||
Remark:
|
||||
: For now Krambook accept only macros _without_ any parameter. Here are some examples:
|
||||
|
||||
~~~
|
||||
%%% simple %%% A Simple Macro %%%
|
||||
%%% amacro %%% a
|
||||
macro
|
||||
on many lines %%%
|
||||
%%% code %%% ruby: "a"*3 %%%
|
||||
%%% complex %%% ruby: (1..5).map do |x|
|
||||
x*x
|
||||
end.join(" : ") %%%
|
||||
~~~
|
||||
|
||||
These transformations will occur on the markdown file before it is transformed in %latex.
|
||||
|
||||
You can also declare macro that will be processed after the file was transformed in %latex or in HTML.
|
||||
|
||||
<pre>
|
||||
LLL tex LLL \TeX LLL TeX HTML
|
||||
LLL tex_ LLL \TeX{} LLL TeX HTML
|
||||
</pre>
|
||||
|
||||
In markdown, you simply write \%macroname or \%code
|
||||
and it will be transformed correctly in your pdf.
|
||||
|
42
content/01_Install.md
Normal file
42
content/01_Install.md
Normal file
|
@ -0,0 +1,42 @@
|
|||
# Install
|
||||
|
||||
If you are reading these lines
|
||||
chances are great that your system contains all necessary packages.
|
||||
But here are the dependencies:
|
||||
|
||||
- ruby,
|
||||
- rake,
|
||||
- %kramdown[^1]
|
||||
|
||||
Optionally you'll need:
|
||||
|
||||
- %latex (more precisely %xelatex) to generate PDF output,
|
||||
- MathJax to draw correctly math formulae inside HTML website,
|
||||
- `pdf2svg` to generate the SVG oriented website.
|
||||
|
||||
[^1]: %kramdown is an amelioration of the original markdown format.
|
||||
|
||||
1. You'll need to install ruby and rake.
|
||||
They should be present on your system.
|
||||
But if you are using Ubuntu the following command line should be enough:
|
||||
|
||||
[Ubuntu]> sudo apt-get install ruby rake
|
||||
|
||||
2. In order to install the %kramdown gem:
|
||||
|
||||
> gem install kramdown
|
||||
|
||||
3. To install %xelatex, I suggest you to use [TexLive](http://www.tug.org/texlive/) full install to be certain not lacking anything.
|
||||
Of course you are free to use any other distribution that suit you better.
|
||||
|
||||
4. Download [MathJax](http://www.mathjax.org)
|
||||
|
||||
5. Finally Download the [source code](http://github.com/yogsototh/krambook) and copy the MathJax directory into `site/js/`.
|
||||
|
||||
Verify if all work correctly by running:
|
||||
|
||||
> rake
|
||||
> rake html
|
||||
|
||||
Congratulation you are ready.
|
||||
|
150
content/02_Tutorial.md
Normal file
150
content/02_Tutorial.md
Normal file
|
@ -0,0 +1,150 @@
|
|||
# Tutorial
|
||||
|
||||
## Firsts steps
|
||||
|
||||
I suppose you have a correct install of %latex.
|
||||
|
||||
If you had not yet verified try to launch the following:
|
||||
|
||||
> rake
|
||||
|
||||
It should create a `krambook.pdf` file.
|
||||
|
||||
Now it is time to create your own book:
|
||||
|
||||
- Edit the `config.rb` file (set title, author name and the pdf filename)
|
||||
- Create and write files in the `content` folder.
|
||||
You should write them using the [kramdown](http://kramdown.rubyforge.org/) format.
|
||||
Very close to the %mardown format.
|
||||
|
||||
Remark:
|
||||
: by default file are sorted by name. I suggest you to name your files and folder with number prefixes. For example like `00_intro.md`, `01_section/01_subsection.md`, etc... You can make a bit of `ruby` (search `@filelist` in the `Rakefile` file) to change this behaviour.
|
||||
|
||||
- run `rake` (or `rake compile`) to create and show a `.pdf` file.
|
||||
- run `rake html` and launch `unicorn` (`gem install unicorn`) then look at the website at `http://localhost:8080/`,
|
||||
- run `rake clean` to remove temporary files,
|
||||
- run `rake clobber` to remove all generated files
|
||||
|
||||
|
||||
With just that you can already write a book.
|
||||
You can make as many as file as you want.
|
||||
Every file of the form: `content/**/*.md` will be used to create the book.
|
||||
|
||||
## Macros
|
||||
|
||||
Now you can write the content of your book mostly in %kramdown format.
|
||||
But with some simple additions: _macros_.
|
||||
|
||||
Remark:
|
||||
: For now Krambook accept only macros _without_ any parameter. Here are some examples:
|
||||
|
||||
~~~
|
||||
%%% simple %%% A Simple Macro %%%
|
||||
%%% amacro %%% a
|
||||
macro
|
||||
on many lines %%%
|
||||
%%% code %%% ruby: "a"*3 %%%
|
||||
%%% complex %%% ruby: (1..5).map do |x|
|
||||
x*x
|
||||
end.join(" : ") %%%
|
||||
~~~
|
||||
|
||||
These transformations will occur on the markdown file before it is transformed in %latex.
|
||||
|
||||
You can also declare macro that will be processed after the file was transformed in %latex or in HTML.
|
||||
|
||||
<pre>
|
||||
LLL tex LLL \TeX LLL TeX HTML
|
||||
LLL tex_ LLL \TeX{} LLL TeX HTML
|
||||
</pre>
|
||||
|
||||
In markdown, you simply write \%macroname or \%code
|
||||
and it will be transformed correctly in your pdf.
|
||||
|
||||
## Some other macros examples
|
||||
|
||||
MACRO(tldr) = Too long don't read ENDMACRO
|
||||
MACRO(multiline) = a
|
||||
multiline
|
||||
macro ENDMACRO
|
||||
MACRO(ruby) = ruby: "a"*3 ENDMACRO
|
||||
MACRO(complex) = ruby: (1..5).map do |x|
|
||||
x*x
|
||||
end.join(" : ") ENDMACRO
|
||||
|
||||
POSTMACRO(latex) = LATEX: \LaTeX HTML: LaTeX ENDMACRO
|
||||
POSTMACRO(tldr) = LATEX: {\em Too long don't read: } HTML: <em>Too long don't read: </em> ENDMACRO
|
||||
|
||||
It is a simple demonstration of how macros are working.
|
||||
They were declared inside the markdown like this:
|
||||
|
||||
~~~
|
||||
%%% multiline %%% a
|
||||
multiline
|
||||
macro %%%
|
||||
%%% ruby %%% ruby: "a"*3 %%%
|
||||
%%% complex %%% ruby: (1..5).map do |x|
|
||||
x*x
|
||||
end.join(" : ") %%%
|
||||
LLL latex LLL \LaTeX LLL LaTeX HTML
|
||||
LLL tldr LLL {\em Too long don't read: } LLL <em>Too long don't read: </em> HTML
|
||||
~~~
|
||||
|
||||
Now if I write:
|
||||
|
||||
> \%tldr A simple demonstration of how macros are working.
|
||||
|
||||
It renders as:
|
||||
|
||||
%beginbox
|
||||
|
||||
> %tldr A simple demonstration of how macros are working.
|
||||
|
||||
%endbox
|
||||
|
||||
The \%multine macro render as:
|
||||
|
||||
%beginbox
|
||||
|
||||
> %multiline
|
||||
|
||||
%endbox
|
||||
|
||||
The output should be in %latex and
|
||||
was compiled from a markdown-like format.
|
||||
|
||||
- Simple list ;
|
||||
- Example ;
|
||||
- Another one item.
|
||||
|
||||
~~~~~
|
||||
Hello there
|
||||
|
||||
this is some code block
|
||||
~~~~~
|
||||
|
||||
%latex
|
||||
: Some %latex definition
|
||||
|
||||
A simple math mode $$x_i$$ and a protected one \$$x_i\$$
|
||||
A long formula now:
|
||||
|
||||
$$ \sum_{i=0}^n\sqrt{x_i + y_i} $$
|
||||
|
||||
Even with some ruby code inside:
|
||||
|
||||
Here is the result of the \%ruby macro:
|
||||
|
||||
%beginbox
|
||||
|
||||
%ruby
|
||||
|
||||
%endbox
|
||||
|
||||
and a more complex one (\%complex):
|
||||
|
||||
%beginbox
|
||||
|
||||
%complex
|
||||
|
||||
%endbox
|
|
@ -1,87 +0,0 @@
|
|||
## Some other macros examples
|
||||
|
||||
MACRO(tldr) = Too long don't read ENDMACRO
|
||||
MACRO(multiline) = a
|
||||
multiline
|
||||
macro ENDMACRO
|
||||
MACRO(ruby) = ruby: "a"*3 ENDMACRO
|
||||
MACRO(complex) = ruby: (1..5).map do |x|
|
||||
x*x
|
||||
end.join(" : ") ENDMACRO
|
||||
|
||||
POSTMACRO(latex) = LATEX: \LaTeX HTML: LaTeX ENDMACRO
|
||||
POSTMACRO(tldr) = LATEX: {\em Too long don't read: } HTML: <em>Too long don't read: </em> ENDMACRO
|
||||
|
||||
It is a simple demonstration of how macros are working.
|
||||
They were declared inside the markdown like this:
|
||||
|
||||
~~~
|
||||
%%% multiline %%% a
|
||||
multiline
|
||||
macro %%%
|
||||
%%% ruby %%% ruby: "a"*3 %%%
|
||||
%%% complex %%% ruby: (1..5).map do |x|
|
||||
x*x
|
||||
end.join(" : ") %%%
|
||||
LLL latex LLL \LaTeX LLL LaTeX HTML
|
||||
LLL tldr LLL {\em Too long don't read: } LLL <em>Too long don't read: </em> HTML
|
||||
~~~
|
||||
|
||||
Now if I write:
|
||||
|
||||
> \%tldr A simple demonstration of how macros are working.
|
||||
|
||||
It renders as:
|
||||
|
||||
%beginbox
|
||||
|
||||
> %tldr A simple demonstration of how macros are working.
|
||||
|
||||
%endbox
|
||||
|
||||
The \%multine macro render as:
|
||||
|
||||
%beginbox
|
||||
|
||||
> %multiline
|
||||
|
||||
%endbox
|
||||
|
||||
The output should be in %latex and
|
||||
was compiled from a markdown-like format.
|
||||
|
||||
- Simple list ;
|
||||
- Example ;
|
||||
- Another one item.
|
||||
|
||||
~~~~~
|
||||
Hello there
|
||||
|
||||
this is some code block
|
||||
~~~~~
|
||||
|
||||
%latex
|
||||
: Some %latex definition
|
||||
|
||||
A simple math mode $$x_i$$ and a protected one \$$x_i\$$
|
||||
A long formula now:
|
||||
|
||||
$$ \sum_{i=0}^n\sqrt{x_i + y_i} $$
|
||||
|
||||
Even with some ruby code inside:
|
||||
|
||||
Here is the result of the \%ruby macro:
|
||||
|
||||
%beginbox
|
||||
|
||||
%ruby
|
||||
|
||||
%endbox
|
||||
|
||||
and a more complex one (\%complex):
|
||||
|
||||
%beginbox
|
||||
|
||||
%complex
|
||||
|
||||
%endbox
|
|
@ -1,13 +1,7 @@
|
|||
% Author Yann Esposito©2010
|
||||
%!TEX TS-program = xelatex
|
||||
%!TEX encoding = UTF-8 Unicode
|
||||
\documentclass[10pt]{memoir}
|
||||
|
||||
% to use \it, \sc, \tt and \bf with memoir class
|
||||
\renewcommand{\it}{\itshape}
|
||||
\renewcommand{\sc}{\scshape}
|
||||
\renewcommand{\tt}{\texttt}
|
||||
\renewcommand{\bf}{\textbf}
|
||||
\documentclass[10pt,oldfontcommands]{memoir}
|
||||
|
||||
% -- XeLaTeX --
|
||||
\XeTeXdefaultencoding utf-8
|
||||
|
|
Loading…
Reference in a new issue