% !TEX TS-program = lualatex % encoding : utf8 % Documentation of tkzexample.sty % Copyright 2022 Alain Matthes % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3 or later is part of all distributions of LaTeX % version 2005/12/01 or later. % This work has the LPPL maintenance status “maintained”. % The Current Maintainer of this work is Alain Matthes. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % doc tkzexample.sty encodage : utf8 % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Créé par Alain Matthes le 21/03/2009 % % Copyright (c) 2009, 2022 __AlterMundus__ All rights reserved.% % version : 1.45c % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \PassOptionsToPackage{unicode}{hyperref} \documentclass[DIV = 14, fontsize = 10, index = totoc, twoside, cadre, headings = small, ]{tkz-doc} %\usepackage{etoc} \gdef\tkznameofpack{tkzexample.sty} \gdef\tkzversionofpack{1.45c} \gdef\tkzdateofpack{\today} \gdef\tkznameofdoc{doc-tkzexample} \gdef\tkzversionofdoc{1.45c} \gdef\tkzdateofdoc{\today} \gdef\tkzauthorofpack{Alain Matthes} \gdef\tkzadressofauthor{} \gdef\tkznamecollection{AlterMundus} \gdef\tkzurlauthor{http://altermundus.fr} \gdef\tkzengine{lualatex} \gdef\tkzurlauthorcom{http://altermundus.fr} \nameoffile{\tkznameofpack} % -- Packages --------------------------------------------------- \usepackage[dvipsnames,svgnames]{xcolor} \usepackage{calc} \usepackage{tkz-euclide,tkzexample,pgfornament} \usetikzlibrary{backgrounds} \usepackage[colorlinks,pdfencoding=auto, psdextra]{hyperref} \hypersetup{ linkcolor=Gray, citecolor=Green, filecolor=Mulberry, urlcolor=NavyBlue, menucolor=Gray, runcolor=Mulberry, linkbordercolor=Gray, citebordercolor=Green, filebordercolor=Mulberry, urlbordercolor=NavyBlue, menubordercolor=Gray, runbordercolor=Mulberry, pdfsubject={Euclidean Geometry}, pdfauthor={\tkzauthorofpack}, pdftitle={\tkznameofpack}, pdfcreator={\tkzengine} } \usepackage{fontspec} \setmainfont{texgyrepagella}[ Extension = .otf, UprightFont = *-regular , ItalicFont = *-italic , BoldFont = *-bold , BoldItalicFont = *-bolditalic ] \setsansfont{texgyreheros}[ Extension = .otf, UprightFont = *-regular , ItalicFont = *-italic , BoldFont = *-bold , BoldItalicFont = *-bolditalic , ] \setmonofont{lmmono10-regular.otf}[ Numbers={Lining,SlashedZero}, ItalicFont=lmmonoslant10-regular.otf, BoldFont=lmmonolt10-bold.otf, BoldItalicFont=lmmonolt10-boldoblique.otf, ] \newfontfamily\ttcondensed{lmmonoltcond10-regular.otf} %% (La)TeX font-related declarations: \linespread{1.05} % Pagella needs more space between lines %\usepackage{unicode-math} \usepackage[math-style=literal,bold-style=literal]{unicode-math} \usepackage{fourier-otf} \let\rmfamily\ttfamily \usepackage{multicol,lscape} \usepackage[english]{babel} \usepackage[normalem]{ulem} \usepackage{multirow,multido,booktabs,cellspace} \usepackage{shortvrb,fancyvrb,bookmark} \usetikzlibrary{snakes} %<-------------------------------------------------------------------------- % settings styles \tkzSetUpColors[background=white,text=black] \AtBeginDocument{\MakeShortVerb{\|}} % link to shortvrb %<–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––> \begin{document} \parindent=0pt \tkzTitleFrame{tkzexample\\Presentation tool} \clearpage \nameoffile{\tkznameofpack} \defoffile{\tkzname{\tkznameofpack} is a package to present examples and their sources. It is essential if you want to compile the documentation of my packages like \tkzname{tkz-euclide}. I needed for my first packages to work in UTF8 and to present my sources in French. These sources had accents so I had to adapt the code used by \tkzimp{T.Tantau} to present the examples of \tkzname{pgfmanual}. There are still some imperfections so I invite you to improve this code if necessary}. \presentation \vfill Please report typos or any other comments to this documentation to: \href{mailto:al.ma@mac.com}{\textcolor{blue}{Alain Matthes}}. This file can be redistributed and/or modified under the terms of the \LaTeX{} Project Public License Distributed from \href{http://www.ctan.org/}{CTAN}\ archives. \clearpage \tableofcontents \clearpage %<–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––> \colorlet{graphicbackground}{blue!10!white}% \colorlet{codebackground}{blue!20!lightgray!20}% \colorlet{numbackground}{blue!50!black!50}% \colorlet{numcolor}{white}% \section{First example : no options} \tkzname{\tkznameofpack} is based on the code of \tkzname{codeexample} of \tkzimp{T.Tantau} . I wanted to be able to use the accents of the French language in the sources. How to use this environment? Without any options, the interpretation of a code and the source of this code are placed one above the other. To do this, simply place the source code in a \tkzname{tkzexample}. The colors of the different boxes show their sizes. The colors are obtained as follows: |\colorlet{graphicbackground}{blue!10!white}| \\ |\colorlet{codebackground}{blue!20!lightgray!20}|\\ \begin{tkzexample}[] \begin{minipage}{8cm} \subsubsection{Minipage and accents without options} This is a test for "minipage" and accents èçéà\&§. The brackets |[]| even without options are mandatory. \end{minipage} \end{tkzexample} \vspace{12pt} |\begin{tkzexample}[]|\\ |\begin{minipage}{8cm}|\\ |\subsubsection{Minipage and accents without options}|\\ |This is a test for "minipage" and accents èçéà\&§. |\\ | The brackets |[]| even without options are mandatory.|\\ |\end{minipage}|\\ |\end{tkzexample}|\\ \vspace{12pt} You may notice already a small default, |[]| square brackets are mandatory even without option. \section{Inversion of the boxes: option \tkzname{overhang}} \tkzname{overhang} allows to swap the source and the result. |\begin{tkzexample}[overhang]|\\ |\begin{tikzpicture}|\\ | ...|\\ |\end{tkzexample}|\\ \begin{tkzexample}[overhang] \begin{tikzpicture} \tkzDefPoint(0,0){O} \tkzDefPoint(1,0){a0} \tkzDrawSegment(O,a0) \foreach \i [count=\j] in {0,...,16}{% \tkzDefPointWith[orthogonal normed](a\i,O) \tkzGetPoint{a\j} \pgfmathsetmacro{\c}{5*\i} \tkzDrawPolySeg[fill=teal!\c](a\i,a\j,O)} \end{tikzpicture} \end{tkzexample} \newpage \section{Boxes with the same width: option \tkzname{vbox}} In order to present the code under the interpretation, I set the vbox option so that the interpretation and the source are in a box of the same maximum width. \vspace{12pt} |\begin{tkzexample}[vbox]|\\ | ...|\\ |\end{tkzexample}|\\ \vspace{12pt} which gives \begin{tkzexample}[vbox] \begin{tikzpicture}[scale=1] \tikzset{new/.style={color=orange,line width=.2pt}} \tkzDefPoint(0,0){A}\tkzDefPoint(6,0){D} \tkzDefPoint(8,0){B}\tkzDefPoint(4,0){I} \tkzDefLine[orthogonal=through D](A,D) \tkzInterLC[R](D,tkzPointResult)(I,4) \tkzGetSecondPoint{C} \tkzDefLine[orthogonal=through C](I,C) \tkzGetPoint{c} \tkzDefLine[orthogonal=through B](A,B) \tkzGetPoint{b} \tkzInterLL(C,c)(B,b) \tkzGetPoint{T} \tkzInterLL(A,T)(C,D) \tkzGetPoint{P} \tkzDrawArc(I,B)(A) \tkzDrawSegments(A,B A,T C,D I,C) \tkzDrawSegment[new](I,C) \tkzDrawLine[add = 1 and 0](C,T) \tkzDrawLine[add = 0 and 1](B,T) \tkzMarkRightAngle(I,C,T) \tkzDrawPoints(A,B,I,D,C,T) \tkzLabelPoints(A,B,I,D) \tkzLabelPoints[above right](C,T) \tkzMarkSegment[pos=.25,mark=s|](C,D) \tkzMarkSegment[pos=.75,mark=s|](C,D) \end{tikzpicture} \end{tkzexample} \newpage \section{Side by side: option \tkzname{latex}} You must indicate the width of the box assigned to the interpretation, this is done with the option \tkzname{latex}: \subsubsection{\tkzname{latex=7cm}} \begin{tkzexample}[latex=7cm] \begin{tikzpicture}[scale=.5] \tkzInit[xmin=-6,ymin=-4,xmax=6,ymax=6] \tkzClip \tkzSetUpLine[thin,color=teal] \tkzDefPoint(0,0){O} \tkzDefPoint(132:5){A} \tkzDefPoint(4,0){B} \foreach \ang in {5,10,...,360}{% \tkzDefPoint(\ang:4){M} \tkzDefLine[mediator](A,M) \tkzGetPoints{x}{y} \tkzDrawLine[add= 3 and 3](x,y)} \end{tikzpicture} \end{tkzexample} |\begin{tkzexample}[latex=7cm]|\\ |...| \\ |\end{tkzexample}| \\ \subsubsection{\tkzname{latex=8cm}} \begin{tkzexample}[latex=8cm] \begin{tikzpicture}[scale=.5] \tkzInit[xmin=-6,ymin=-4,xmax=6,ymax=6] \tkzClip \tkzSetUpLine[thin,color=magenta] \tkzDefPoint(0,0){O} \tkzDefPoint(132:4){A} \tkzDefPoint(5,0){B} \foreach \ang in {5,10,...,360}{% \tkzDefPoint(\ang:5){M} \tkzDefLine[mediator](A,M) \tkzGetPoints{x}{y} \tkzDrawLine[add= 3 and 3](x,y)} \end{tikzpicture} \end{tkzexample} |\begin{tkzexample}[latex=8cm]|\\ |...| \\ |\end{tkzexample}| \\ \newpage \section{Side by side: option \tkzname{width}} If the option \tkzname{latex= x cm} allows to reserve a box of width x cm for the code, the option \tkzname{width= x cm} allows to reserve a box of width x cm for the result. We leave a box of 8cm for the result or drawing and the rest of the line will contain a minipage of 8cm. As you can see a new section has been created and the code is contained in a 8cm box \begin{tkzexample}[overhang,width=6cm,code=red!10] \begin{tikzpicture}[scale=.4] \tkzDefPoints{0/0/P,5/0/Q,3/2/I} \tkzDefCircle[orthogonal from=P](Q,I) \tkzGetFirstPoint{E} \tkzDrawCircles(P,E Q,E) \tkzInterCC[common=E](P,E)(Q,E) \tkzGetFirstPoint{F} \tkzDefPointOnCircle[through = center P angle 80 point E] \tkzGetPoint{A} \tkzInterLC[common=E](A,E)(Q,E) \tkzGetFirstPoint{C} \tkzInterLL(A,F)(C,Q) \tkzGetPoint{D} \tkzDrawLines[add=0 and .75](P,Q) \tkzDrawLines[add=0 and 2](A,E) \tkzDrawSegments(P,E E,F F,C A,F C,D) \tkzDrawPoints(P,Q,E,F,A,C,D) \tkzLabelPoints(P,Q,F,C,D) \tkzLabelPoints[above](E,A) \end{tikzpicture} \end{tkzexample} \vspace{24pt} The options used to get this result are : \vspace{12pt} |\begin{tkzexample}[overhang,width=6cm,code=red!30]|\\ |...| \\ |\end{tkzexample}| \\ \newpage \section{Option \tkzname{code} and option \tkzname{graphic}} This option is used to color the background of the code. \vspace{24pt} |\begin{tkzexample}[overhang,width=9cm,code=gray!20,graphic=red!15]|\\ |...| \\ |\end{tkzexample}| \\ \begin{tkzexample}[overhang,width=9cm,code=gray!20,graphic=red!15] \begin{tikzpicture}[scale=1] \tkzDefPoint(2,3){A} \tkzDefShiftPoint[A](30:3){B} \tkzDefShiftPoint[A](-30:3){C} \tkzDrawPolygon(A,B,C) \tkzDrawPoints(A,B,C) \tkzLabelPoints[right](B,C) \tkzLabelPoints[above left](A) \tkzMarkSegments[mark=|](A,B A,C B,C) \end{tikzpicture} \end{tkzexample} \newpage \section{Option \tkzname{num}} You can number the lines of code. \tkzname{numcolor} and \tkzname{numbkgcolor} are used to define the style of the numbering. \subsection{Example 1} \begin{tkzexample}[width=6cm,num,numcolor=red,numbkgcolor=white,code style=\ttfamily] \begin{tikzpicture}[scale=0.3] \tkzDefPoint(-4,0){I} \tkzDefPoint(4,0){J} \tkzDefPoint(0,0){O} \tkzInterCC(J,O)(O,J) \tkzGetPoints{L}{H} \tkzInterCC(I,O)(O,I) \tkzGetPoints{K}{G} \tkzInterLL(I,K)(J,H) \tkzGetPoint{M} \tkzInterLL(I,G)(J,L) \tkzGetPoint{N} \tkzDefPointsBy[symmetry=center J](L,H){D,E} \tkzDefPointsBy[symmetry=center I](G,K){C,F} \begin{scope}[line style/.style = {very thin,teal}] \tkzDrawLines[add=1.5 and 1.5](I,K I,G J,H J,L) \tkzDrawLines[add=.5 and .5](I,J) \tkzDrawCircles(O,I I,O J,O) \tkzDrawArc[delta=0,orange](N,D)(C) \tkzDrawArc[delta=0,orange](M,F)(E) \tkzDrawArc[delta=0,orange](J,E)(D) \tkzDrawArc[delta=0,orange](I,C)(F) \end{scope} \end{tikzpicture} \end{tkzexample} this is obtained with:\\ |\begin{tkzexample}[width=6cm,num,numcolor=red,numbkgcolor=white,code style=\ttfamily]| \\ |...| \\ |\end{tkzexample}| \\ \subsection{Example 2} \begin{tkzexample}[latex=5cm,code=red!20,num,small,hsep=24pt] \begin{tikzpicture}[scale=.25] \tkzDefPoints{0/0/A,12/0/B,6/12*sind(60)/C} \foreach \density in {20,30,...,240}{% \tkzDrawPolygon[fill=teal!\density](A,B,C) \pgfnodealias{X}{A} \tkzDefPointWith[linear,K=.15](A,B) \tkzGetPoint{A} \tkzDefPointWith[linear,K=.15](B,C) \tkzGetPoint{B} \tkzDefPointWith[linear,K=.15](C,X) \tkzGetPoint{C}} \end{tikzpicture} \end{tkzexample} \vspace{12pt} |\begin{tkzexample}[latex=5cm,code=red!20,num,small]|\\ |...|\\ |\end{tkzexample}|\\ \newpage \vspace{12pt} The global num option allows to have a global numbering of the lines with the next code: \vspace{12pt} |\begin{tkzexample}[latex=7cm,global num,small,hsep=1cm]|\\ |...|\\ |\end{tkzexample}| \begin{tkzexample}[latex=7cm,global num,small,hsep=24pt] \begin{tikzpicture} \tkzSetUpCompass[color=purple,line width=1pt] \tkzDefPoints{0/1/A,5/2/B,3/4/C} \tkzDefEquiPoints[from=C,dist=1,show, /tkzcompass/delta=20](A,B) \tkzGetPoints{E}{H} \tkzDrawLines[color=blue](C,E C,H A,B) \tkzDrawPoints[color=blue](A,B,C) \tkzDrawPoints[color=red](E,H) \tkzLabelPoints(E,H) \tkzLabelPoints[color=blue](A,B,C) \end{tikzpicture} \end{tkzexample} % \pgfqkeys{/tkzexample}{% % every tkzexample/.style={width=8cm+7pt} % } % % | \pgfqkeys{/tkzexample}{%| % | every tkzexample/.style={width=8cm+7pt}| % | }| \newpage \section{Size option for code fonts} The different size options for fonts are : \begin{enumerate} \item very small \begin{tkzexample}[width=8cm,very small] \begin{tikzpicture}[scale=.75] \tkzDefPoints{0/0/A,6/0/B} \tkzDefMidPoint(A,B) \tkzGetPoint{I} \tkzDefPointWith[orthogonal,K=-.75](B,A) \tkzGetPoint{C} \tkzInterLC(B,C)(B,I) \tkzGetPoints{F}{D} \tkzDuplicateSegment(B,F)(A,F) \tkzGetPoint{E} \tkzDrawArc[delta=10](F,E)(B) \tkzInterLC(A,B)(A,E) \tkzGetPoints{N}{M} \tkzDrawArc[delta=10](A,M)(E) \tkzDrawLines(A,B B,C A,F) \tkzCompass(B,F) \tkzDrawPoints(A,B,C,F,M,E) \tkzLabelPoints(A,B,C,F,M) \tkzLabelPoints[above](E) \end{tikzpicture} \end{tkzexample} \item small \begin{tkzexample}[width=6cm,small] \begin{tikzpicture}[scale=1.2] \tkzDefPoints{1/3/A,4/2/B} \tkzDefPointWith[linear,K=0.5](A,B) \tkzGetPoint{C} \tkzDrawPoints[color=red](A,B,C) \tkzDrawSegment(A,B) \tkzLabelPoints[above right=3pt](A,B,C) \end{tikzpicture} \end{tkzexample} \item normal \begin{tkzexample}[width=6cm,normal] \begin{tikzpicture}[scale=.75] \tikzset{new/.style={color=orange, line width=.2pt}} \tkzDefPoints{0/0/O_1,0/1/O_2,0/3/A} \tkzDefPoint(15:3){F} \tkzInterLC(F,O_1)(O_1,A) \tkzGetSecondPoint{E} \tkzDefLine[parallel=through O_2](E,F) \tkzGetPoint{x} \tkzInterLC(x,O_2)(O_2,A) \tkzGetPoints{D}{C} \tkzDrawCircles(O_1,A O_2,A) \tkzDrawSegments[new](O_1,A E,F C,D) \tkzDrawSegments[purple](A,E A,F) \tkzDrawPoints(A,O_1,O_2,E,F,C,D) \tkzLabelPoints(A,O_1,O_2,E,F,C,D) \end{tikzpicture} \end{tkzexample}\end{enumerate} \newpage \section{Option \tkzname{code only}} |\begin{tkzexample}[small,code only]| \\ | \begin{minipage}{9cm}| \\ | \thispagestyle{empty}| \\ | \noindent| \\ | \begin{tikzpicture}| \\ | \draw (0,0) node[circle,| \\ | shade,| \\ | ball color=Peach,minimum size=2cm]{};| \\ | \draw[snake = expanding waves,| \\ | color = Peach,| \\ | line width = 3pt](1.2,0)--(4,0);| \\ | \end{tikzpicture}| \\ | \end{minipage}| \\ |\end{tkzexample}| The result \begin{tkzexample}[small,code only] \begin{minipage}{9cm} \begin{tikzpicture} \draw (0,0) node[circle, shade, ball color=Peach,minimum size=2cm]{}; \draw[snake = expanding waves, color = Peach, line width = 3pt](1.2,0)--(4,0); \end{tikzpicture} \end{minipage} \end{tkzexample} \end{document}