mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-19 11:38:05 +02:00
added tikz examples
This commit is contained in:
parent
8ed1c356fc
commit
5970e3280a
6 changed files with 208 additions and 0 deletions
31
tikz/half-space/Makefile
Normal file
31
tikz/half-space/Makefile
Normal file
|
@ -0,0 +1,31 @@
|
|||
SOURCE = half-space
|
||||
DELAY = 80
|
||||
DENSITY = 300
|
||||
WIDTH = 500
|
||||
|
||||
make:
|
||||
pdflatex $(SOURCE).tex -output-format=pdf
|
||||
make clean
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) *.class *.html *.log *.aux
|
||||
|
||||
gif:
|
||||
pdfcrop $(SOURCE).pdf
|
||||
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
|
||||
make clean
|
||||
|
||||
png:
|
||||
make
|
||||
make svg
|
||||
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
|
||||
|
||||
transparentGif:
|
||||
convert $(SOURCE).pdf -transparent white result.gif
|
||||
make clean
|
||||
|
||||
svg:
|
||||
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
|
||||
pdf2svg $(SOURCE).pdf $(SOURCE).svg
|
||||
# Necessary, as pdf2svg does not always create valid svgs:
|
||||
inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg
|
50
tikz/half-space/half-space.tex
Normal file
50
tikz/half-space/half-space.tex
Normal file
|
@ -0,0 +1,50 @@
|
|||
\documentclass{article}
|
||||
\usepackage[pdftex,active,tightpage]{preview}
|
||||
\setlength\PreviewBorder{2mm}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{patterns}
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{tikzpicture}
|
||||
\pgfdeclarepatternformonly{north east lines wide}%
|
||||
{\pgfqpoint{-1pt}{-1pt}}%
|
||||
{\pgfqpoint{10pt}{10pt}}%
|
||||
{\pgfqpoint{9pt}{9pt}}%
|
||||
{
|
||||
\pgfsetlinewidth{0.7pt}
|
||||
\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
|
||||
\pgfpathlineto{\pgfqpoint{9.1pt}{9.1pt}}
|
||||
\pgfusepath{stroke}
|
||||
}
|
||||
|
||||
\pgfdeclarepatternformonly{north west lines wide}
|
||||
{\pgfqpoint{-1pt}{-1pt}}%
|
||||
{\pgfqpoint{7pt}{7pt}}%
|
||||
{\pgfqpoint{6pt}{6pt}}%
|
||||
{
|
||||
\pgfsetlinewidth{0.7pt}
|
||||
\pgfpathmoveto{\pgfqpoint{0pt}{6pt}}
|
||||
\pgfpathlineto{\pgfqpoint{6.1pt}{-0.1pt}}
|
||||
\pgfusepath{stroke}
|
||||
}
|
||||
|
||||
% Draw two intersecting lines
|
||||
\draw[thick, red] (-1,-1) coordinate (a) -- (2,-1) coordinate (b);
|
||||
\draw[thick, green] ( 1,-1) coordinate (c) -- (1, 2) coordinate (d);
|
||||
|
||||
\fill[pattern=north east lines wide, pattern color=red!50] (a) -- (b) -- (2,2) -- (-1,2) -- (a);
|
||||
\fill[pattern=north west lines wide, pattern color=green!50] (a) -- (1,-1) -- (1,2) -- (-1,2) -- (a);
|
||||
|
||||
\draw[thick, green] (c) -- (d);
|
||||
\draw[thick, red] (a) -- (b);
|
||||
|
||||
|
||||
% Draw axes
|
||||
\draw [<->,thick] (0,2.5) node (yaxis) [above] {$x_2$}
|
||||
|- (2.5,0) node (xaxis) [right] {$x_1$};
|
||||
\node[red] at (1.5,2.8) {$H_2^+(-1)$};
|
||||
\node[green] at (1.5,2.3) {$H_1^-(1)$};
|
||||
\end{tikzpicture}
|
||||
\end{preview}
|
||||
\end{document}
|
31
tikz/multidimensional-intervall/Makefile
Normal file
31
tikz/multidimensional-intervall/Makefile
Normal file
|
@ -0,0 +1,31 @@
|
|||
SOURCE = multidimensional-intervall
|
||||
DELAY = 80
|
||||
DENSITY = 300
|
||||
WIDTH = 500
|
||||
|
||||
make:
|
||||
pdflatex $(SOURCE).tex -output-format=pdf
|
||||
make clean
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) *.class *.html *.log *.aux
|
||||
|
||||
gif:
|
||||
pdfcrop $(SOURCE).pdf
|
||||
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
|
||||
make clean
|
||||
|
||||
png:
|
||||
make
|
||||
make svg
|
||||
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
|
||||
|
||||
transparentGif:
|
||||
convert $(SOURCE).pdf -transparent white result.gif
|
||||
make clean
|
||||
|
||||
svg:
|
||||
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
|
||||
pdf2svg $(SOURCE).pdf $(SOURCE).svg
|
||||
# Necessary, as pdf2svg does not always create valid svgs:
|
||||
inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg
|
|
@ -0,0 +1,30 @@
|
|||
\documentclass{article}
|
||||
\usepackage[pdftex,active,tightpage]{preview}
|
||||
\setlength\PreviewBorder{2mm}
|
||||
\usepackage{tikz}
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{tikzpicture}
|
||||
% Draw axes
|
||||
\draw [<->,thick] (0,2.5) node (yaxis) [above] {$x_2$}
|
||||
|- (2.5,0) node (xaxis) [right] {$x_1$};
|
||||
|
||||
% Draw two intersecting lines
|
||||
\draw[thick, dashed] (1,1) coordinate (a) -- (2,1) coordinate (b);
|
||||
\draw[thick, dashed] (a) -- (1,2) coordinate (d);
|
||||
\draw[thick] (d) -- (2,2) coordinate (c);
|
||||
\draw[thick] (b) -- (2,2);
|
||||
|
||||
\fill[green!15] (a) -- (b) -- (c) -- (d) -- (a);
|
||||
|
||||
% Draw lines indicating intersection with y and x axis. Here we
|
||||
% use the perpendicular coordinate system
|
||||
\draw[dotted] (yaxis |- a) node[left] {$a_2$}
|
||||
-| (xaxis -| a) node[below] {$a_1$};
|
||||
|
||||
\draw[dotted] (yaxis |- c) node[left] {$b_2$}
|
||||
-| (xaxis -| c) node[below] {$b_1$};
|
||||
\end{tikzpicture}
|
||||
\end{preview}
|
||||
\end{document}
|
31
tikz/riemann-sum/Makefile
Normal file
31
tikz/riemann-sum/Makefile
Normal file
|
@ -0,0 +1,31 @@
|
|||
SOURCE = riemann-sum
|
||||
DELAY = 80
|
||||
DENSITY = 300
|
||||
WIDTH = 512
|
||||
|
||||
make:
|
||||
pdflatex $(SOURCE).tex -output-format=pdf
|
||||
make clean
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) *.class *.html *.log *.aux
|
||||
|
||||
gif:
|
||||
pdfcrop $(SOURCE).pdf
|
||||
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
|
||||
make clean
|
||||
|
||||
png:
|
||||
make
|
||||
make svg
|
||||
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
|
||||
|
||||
transparentGif:
|
||||
convert $(SOURCE).pdf -transparent white result.gif
|
||||
make clean
|
||||
|
||||
svg:
|
||||
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
|
||||
pdf2svg $(SOURCE).pdf $(SOURCE).svg
|
||||
# Necessary, as pdf2svg does not always create valid svgs:
|
||||
inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg
|
35
tikz/riemann-sum/riemann-sum.tex
Normal file
35
tikz/riemann-sum/riemann-sum.tex
Normal file
|
@ -0,0 +1,35 @@
|
|||
% Thanks to http://tex.stackexchange.com/a/30782/5645 for this
|
||||
% example!
|
||||
\documentclass{article}
|
||||
\usepackage[pdftex,active,tightpage]{preview}
|
||||
\setlength\PreviewBorder{2mm}
|
||||
\usepackage{pgfplots}
|
||||
\pgfplotsset{
|
||||
integral segments/.code={\pgfmathsetmacro\integralsegments{#1}},
|
||||
integral segments=3,
|
||||
integral/.style args={#1:#2}{
|
||||
ybar interval,
|
||||
domain=#1+((#2-#1)/\integralsegments)/2:#2+((#2-#1)/\integralsegments)/2,
|
||||
samples=\integralsegments+1,
|
||||
x filter/.code=\pgfmathparse{\pgfmathresult-((#2-#1)/\integralsegments)/2}
|
||||
}
|
||||
}
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{tikzpicture}[/pgf/declare function={f=-15*(x-5)+(x-5)^3+50;}]
|
||||
\begin{axis}[
|
||||
domain=0:10,
|
||||
samples=100,
|
||||
axis lines=middle
|
||||
]
|
||||
\addplot [
|
||||
red,
|
||||
fill=red!50,
|
||||
integral=2:6
|
||||
] {f};
|
||||
\addplot [thick] {f};
|
||||
\end{axis}
|
||||
\end{tikzpicture}
|
||||
\end{preview}
|
||||
\end{document}
|
Loading…
Add table
Add a link
Reference in a new issue