zTeX
is a LaTeX bundle developed by LaTeX 3, that used for writing documents. It consists of 4 parts:
zlatex
: a document class for wrtingNotes
,Books
andSlide
ztikz
: a package mainly for drawing2D diagrams
,plots functions
. It also provide a interface to call the external program likepython
,gnuplot
,mathematica
andmatlab
.ztool(prepare)
: a package for providing some useful tools for LaTeX, likeshipout
,key-value
set,box-align
,command define
andpatch/Hook
etc.(Now has been deprecated)zslide
: a package for beamer.
Users's manual for this bundle is provided in the doc
folder of each module.
Important
Translation Needed, all manuals are written in Chinese now.
For
zTeX bundle
has not been uploaded to CTAN, This Installation guide will put the bundle in your USER's dir for LaTeX.
Download the latest version of the bundle from zTeX bundle latese Release. Unzip the file and copy the files to your LaTeX user's folder, we call it USER-DIR
in the following. In windows, it is usually located at
C:\Users\<YourName>\texmf\tex\latex\
in linux it is usually located at
~/texmf/tex/latex/
then create a new folder named zTeX
in the above USER-DIR
and copy the files to USER-DIR/zTeX
. After doing this, the USER-DIR
structure will be like:
USER-DIR
└── zTeX
├── doc
│ ├── zlatex_manual.pdf
│ ├── ztex_intro.pdf
│ ├── ztikz_manual.pdf
│ └── ztool_manual.pdf
├── modules
│ ├── ztikzmodule.cache.tex
│ ├── ztikzmodule.gnuplot.tex
│ ├── ztikzmodule.python.tex
│ ├── ztikzmodule.wolfram.tex
│ └── ztikzmodule.zdraw.tex
├── zlatex.cls
├── ztikz.sty
└── ztool.sty
If possible, run texhash
to update the database.
Some detailed developing notes and bundle discription etc, are consist in ztex_intro
. Feel free to read it ! If you just want to use this bundle immediately, see the following Basic Usage section for detailed guide.
For detailed guide on how to use this bundle, please see the manuals in this Bundle.
1. Are you always feel confused by the argument position and the corresponding meaning when using a LaTeX commands? zLaTeX
solve this, most commands in zlatex
is implemented as a key-value
form, that makes you easy to use these commands. Some examples are:
slide mode
metadata setup
\zslideSetup{
sec = {bg=ColorC, fg=white, prefix=\ding{73}\ },
UL = {bg = ColorA, text=UL-TEXT\textcolor{white}{WHITE}, fg=ColorB},
UR = {text={\ifnum\arabic{subsection}=0\else Subsection\ \thesubsection\fi}},
BC = {text={\hyperlink{zslide-title-page}{\zslideTitle}}},
}
- example for
zlatex
options setup
\zlatexSetup{
font = load, % require xetex or luatex
toc = {
column = 3,
title = \hfill\large\normalfont CONTENTS {\sffamily\small NEW}\hfill,
title-vspace = -5em
},
mathSpec = {
alias=true,
font=euler,
envStyle=paris
},
bib_index = {
load,
source=ref.bib,
backend=biber
}
}
2. Are you always satisfied with the options provided by a LaTeX package or class ? zlatex
provides the user so many options with default values to set up. Including:
document class
you used for writing, class options passing support.- flexible
page layout
andside notes
including figure in the margin. - Many predefined theorem env styles and math font. You can also use your own env style by
HOOK
option provided byzlatex
. - Easy to transform your
article
orbook
to slide, if you usezlatex
then you don't need to copy your source to a new beamer class and modify or add something in. - Custom makes easy in
slide mode
, in slide modezlatex
provides a command\zslideSetup
for custom slide theme, slide metadata, slide toc format, etc. - Easy to expand ! For example, you can easily add other languags or math env using the inner commands
\zlatex_keys_define:nn
or the pre-defined hooks\zlatex_hook_preamble_last:n
,\zlatex_hook_doc_begin:n
to make your own commands or environment - ...
3. Do you complain about the speed of a template ? zLaTeX
will checks the options you passed to it and loads the corresponding packages, that makes this template runs blazing fast by default. BTW, zlatex
will load the neccessary packags instead of loading nothing to speed up the compiling.
4. Can you understand the ouput error(warning) messages(log) when compiling ? zlatex
implements a user-friendly message(log) system to tell the user what happend and how to deal with it. The message generated by zlatex
something like this:
Class zlatex Warning: You use an invalid key "font" or key assign for it in
(zlatex) the meta key "mathSpec", Valid options
(zlatex) are:newtx,mtpro2,euler,mathpazo; Assignment Ignored and
(zlatex) LaTeX default mathSpec settings substitute.
Class zlatex Warning: You use an invalid key "counter" or key assign for it in
(zlatex) the meta key "mathSpec", Valid options
(zlatex) are:alias(<bool>:false),envStyle,font(<choice>:newtx,mtpr
o2,euler,mathpazo);
(zlatex) Assignment Ignored and LaTeX default mathSpec settings
(zlatex) substitute.
Class zlatex Warning: You use an invalid key "openAll" or key assign for it in
(zlatex) the meta key "layout", Valid options
(zlatex) are:margin(<bool>:false),slide,aspect; Assignment
(zlatex) Ignored and LaTeX default layout settings substitute.
sometimes, zlatex
will automatically corrects the wrong commands for you and leaving a warning message:
Class zlatex Warning: MathEnv style:'paris' requires package 'tcolorbox' and
(zlatex) 'tikz', But either of them hasn't been loaded in your
(zlatex) preamble. Reset to default 'plain' style now.
there are many other user-friendly features in zlatex
, use it now ? See the following guide for a good starting.
A minimal working example acting as article
is shown below:
\documentclass{zlatex}
\begin{document}
% your contents here
\end{document}
To use the book
class for writing, an example may be:
\documentclass[class=book]{zlatex}
\begin{document}
\maketitle
\frontmatter
\tableofcontents
\mainmatter
\chapter{First Chapter}
\section{First section}
% your contents here
\end{document}
To transform your article
or book
to slide
, you need to add a slide
option to layout
key in class option. An example maybe:
\documentclass[
layout={slide, aspect=16|9}
]{zlatex}
\begin{document}
% 1. your original contents writing in 'article' or 'book' here.
% 2. zlatex will automatically handle the original material in a proper way.
\end{document}
zlatex
now support 2 languages: english
and chinses
, set the lang
class option to en
or cn
to enable it. Set this key like:
\documentclass[lang=cn]{zlatex}
default language is english
.
There are so many options pre-defined in zlatex
, please see the manual for more information.
There are so many options pre-defined in zlatex
, please see the manual for more information. Some options can only be declared in preamble, like: fancy
, class
while some can be used both preamble and after \begin{document}
.
Option | class option | \zlatexSetup |
---|---|---|
lang | ✅ | ❌ |
hyper | ✅ | ❌ |
fancy | ✅ | ❌ |
class | ✅ | ❌ |
classOption | ✅ | ❌ |
packageOption | ✅ | ❌ |
toc | ✅ | ✅ |
font | ✅ | ✅ |
layout | ✅ | ❌ |
section | ✅ | ✅ |
mathSpec | ✅ | ✅ |
bib_index | ✅ | ✅ |
Use command
\ztikzLoadModule{<module name>}
to load the ztikz
to load the submodule of ztikz that you need. All available submodules are:
cache
gnuplot
python
wolfram
zdraw
Caution
All these modules in ztikz
need you to turn shell escape
on. Be cautious when using this module.
To make ztikz
run in your local, there are some additional settings you need to do. ztikz
split it's macros to different modules according to functions these macros play on. Now, the main modules are:
cache
: used to cache the result of the previous call of external programs. The cache function for original tikz is provided by tkz libraryexternal
. Others are implemented by command\ztikz_hash_if_change_cs:n {<file-name>}
.gnuplot
: use gnuplot to generate plot data, tikz to plot to data generated by gnuplot. This is blazing fast when you plot some complex functions compare to the default tikz.python
: call the external python to plot figure, do calculation. For example,Sympy
can be used to calculate the integral or do some matrix operations in linear algebra.wolfram
: usewolframscript
to do calculations, include plotting figures.zdraw
: this module provide some useful commands to draw ashaded object
,a function
. This module is implemented byl3draw
, thus you don't need to loadtikz
for some simple plotting tasks, just load this module and play with it.
Each module can be loaded and used separately.Find out what you need and install the corresponding external program.
Only wolframscript
, gnuplot
and python
need additional settings. I'll simply introduc how to config this environments the following, for detailed instructions, please read the corresponding sections in the providing manuals.
Caution
All these modules is based on sed
, for linux user, it is easy to handle. For windows users, you may need to using one of the ways: Cygwin, MSYS2, WSL or a package manager
to install sed
.
- For gnuplot setup:
- in linux, you can use your package manager to install it. On windows, using scoop or chocolatey or Download the
EXE
in the official gnuplot site: gnuplot. - check if the gnuplot can been accessed in your shell.
- compile your document turning
shell escape
on.
- in linux, you can use your package manager to install it. On windows, using scoop or chocolatey or Download the
- For python setup:
- install python first
- using your package manager to install
matplotlib
andsympy
- check installations, then all is done.
- compile your document turning
shell escape
on.
- For wolframscript:
- please see the official installations on wolframscript Installation
- If you already have wolframscript setup in your windows, then you can create a soft link in WSL to make it works in your WSL:
ln -sf "/mnt/c/Program Files/Wolfram Research/WolframScript/wolframscript.exe" /usr/bin/wolframscript
pay attention to the wolframscript folder.
- If wolframscript setup successfully, then everything is done.
- compile your document turning
shell escape
on.
A series of basic examples to test different modules in ztikz
listed below:
gnuplot
example:
\documentclass{standalone}
\usepackage{ztikz}
\ztikzLoadModule{gnuplot}
\begin{document}
\begin{tikzpicture}
\Plot[-1.5*pi:2*pi]{sin(x)}
\end{tikzpicture}
\end{document}
The output will be:
python
example:
\documentclass{standalone}
\usepackage{ztikz}
\ztikzLoadModule{python}
\begin{document}
\(\displaystyle\int x^8 + \cos(7x) + 6t\,\mathrm{d}x = \sympy{integrate( x**8 + cos(7*x) + 6*t, x )}\)
\end{document}
The output will be:
wolframscript
example:
\documentclass{standalone}
\usepackage{ztikz}
\ztikzLoadModule{cache, wolfram}
\begin{document}
% call the wolframscript
\wolfram{Series[Exp[x], {x, 0, 5}]}
% import the result
\(\wolframResult\)
\end{document}
The fisrt time you compile it, there will be a log:
current hash is 637191695943FF88742EB181936998A6
current hash is unique --> recorded
that means ztikz
has successfully generates the result and remeber this call (by the wolframscript file hash
).
the next time you compile it, there will be a log:
current hash is 637191695943FF88742EB181936998A6
skip recompile, using the cache wolframscript result 1
and this time is much faster than before. Only when you change this call args(Series[Exp[x], {x, 0, 5}]
), the wolframscript
will be called again.
The output will be:
cache
example: see the above examples for wolframscript. We implement the first example aboutgnuplot
withcache
. The code will be:
\documentclass{standalone}
\usepackage{ztikz}
\ztikzLoadModule{cache, gnuplot}
\begin{document}
\begin{tikzpicture}
\Plot[-1.5*pi:2*pi]{sin(x)}
\end{tikzpicture}
\end{document}
the second time you compile it, there will be a log:
===== Image 'ztikz_output/tikz_data/test-figure0' is up-to-date. ======
that means this time we use the cache result generated in the first time.
zdraw
example:
\documentclass{article}
\usepackage{ztikz}
\ztikzLoadModule{zdraw}
\begin{document}
\begin{zdraw}
\zplot[
domain={0, 0.02*\c_pi_fp, 2*\c_pi_fp},
action=shade, startColor=blue,
endColor=green, axis=x
]{sin(x)}
\end{zdraw}
\end{document}
The output will be:
To compile the users' manuals of this bundle, switching to the module directory and use l3build doc
to compile the corresponding manual. Building the ztikz
manual from scratch will take a long time, be patient(in my computer, about 7 mins). For that there are so many tikz pictures and external programs called in the manual. The second time you compile it, it will be much faster(about 20s).
For better output, Set
typesetruns = 3
to typeset this manual.
For zlatex
, ztex_intro
and ztool
manual, it will be much faster than ztikz
manual.
In slide mode, zlatex
uses these 3 basic commands:
\_zslide_status_bar:nnnn {<start point>}{<bar color Tag>}{<rule width>}{<rule height>}
\_slide_status_metadate:nnn {<head/foot>}{<start x-coor>}{<hbox width>}{<hbox content>}
\_slide_metadate:n {<bar tag>}
to create the status bar
, status metadata box
and status metadata
. You can use these commands to create your slide own theme.
Maybe in the future,
zlatex
will provide a more interfaces to advanced users.
In ztikz
, the uniformal interface of external programs calling hasn't been implemented yet. They are still in separate modules. You still can the following commands to create your own commands:
\ztikz_gnu_data_plot_cs:nnn {<plot type>}{<plot style>}{<plot marker key-value list>}
This function will check the plot type
and check the cache. Finaly it will the plot data generated by gnuplot
.
\ztikz_wolfram_input_result_cs:
This command will automatically write and collects the contents in file \g__ztikz_mma_path_tl/mma_res_\int_use:N \g__mma_text_index_int.txt
, where:
\g__ztikz_mma_path_tl
default set to './ztikz_output/mma_data/'\g__mma_text_index_int
is the index of cache file, and push the content which is separated be comma (,
) to variable\l__wolfram_temp_res_tl
for further use.
After run this command, you can use the content using command \wolframResult
, the implement of this command is:
% macro storage the mma-result
\NewDocumentCommand\wolframResult{O{raw}O{}}{
\tl_if_eq:nnTF {#1}{raw}{
\seq_use:Nnnn \l__wolfram_temp_res_seq {#2}{#2}{#2}
}{
\if_is_int:xTF {\int_eval:n {#1}}
{\seq_item:Nn \l__wolfram_temp_res_seq {#1}}{}
}
}
Preparing ...
This bundle uses l3build
to run code testing. If you want to improve this project and Pull a Request after changing code in class
, package
or module
, make sure to run the test and pass it before you commit your code.
Tip
Be cautious the checkruns
variable when running the test for doc-XX-output
, where XX
represents article
, book
or slide
. The last member need at least 3
run-times to pass the PDF
-based test while the rest need 2
run-times.
Each module contains a Manifest
that discripes:
- Source files
- Checking-specific support files
- Test files
of each module. To get the Manifest.md
, Tips in l3doc.pdf
:
In order for manifest to detect derived and typeset files, it should be run after running unpack and doc.
By setting the variable modules
in ./build.lua
in root dir or change to the module dir.
- Take
ztool
for an example, change directory toztool
module and run the following command:
l3build save ztool-cmd-ztool
- Or set
modules = {"ztool"}
in./build.lua
and run the following command in root dir:
l3build save ztool-cmd-ztool
WELCOME TO CONTRIBUTE TO THIS PROJECT !