diff options
-rw-r--r-- | Master/texmf-dist/doc/latex/bondgraphs/Makefile | 24 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/bondgraphs/README | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/bondgraphs/bondgraphs.pdf | bin | 0 -> 363830 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/bondgraphs/bondgraphs.dtx | 851 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/bondgraphs/bondgraphs.ins | 57 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/bondgraphs/bondgraphs.sty | 184 | ||||
-rwxr-xr-x | Master/tlpkg/bin/tlpkg-ctan-check | 2 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/bondgraphs.tlpsrc | 0 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/collection-pictures.tlpsrc | 1 |
9 files changed, 1122 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/bondgraphs/Makefile b/Master/texmf-dist/doc/latex/bondgraphs/Makefile new file mode 100644 index 00000000000..cfc4e59cbf3 --- /dev/null +++ b/Master/texmf-dist/doc/latex/bondgraphs/Makefile @@ -0,0 +1,24 @@ + + +NAME=bondgraphs +ARCHIVE_NAME=$(NAME).tar.gz +ARCHIVE_CONTENTS=$(NAME).dtx Makefile README $(NAME).ins $(NAME).pdf + +all: sty pdf + +pdf: sty + pdflatex $(NAME).dtx > $(NAME).log + pdflatex $(NAME).dtx >> $(NAME).log + makeindex -s gglo.ist -o $(NAME).gls $(NAME).glo >> $(NAME).log + makeindex -s gind.ist -o $(NAME).ind $(NAME).idx >> $(NAME).log + pdflatex $(NAME).dtx >> $(NAME).log + +sty: + rm -f $(NAME).sty + tex $(NAME).ins > $(NAME).log + +archive: + @ tar -czf $(ARCHIVE_NAME) $(ARCHIVE_CONTENTS) + +clean: + rm -f $(NAME).{log,idx,ilg,ind,aux,blg,bbl,out,gls,glo,fdb_latexmk,synctex.gz,fls,sty,hd,pdf} diff --git a/Master/texmf-dist/doc/latex/bondgraphs/README b/Master/texmf-dist/doc/latex/bondgraphs/README new file mode 100644 index 00000000000..e9bdc45df8e --- /dev/null +++ b/Master/texmf-dist/doc/latex/bondgraphs/README @@ -0,0 +1,4 @@ +The bondgraphs package allows for easy and neat bondgraph drawing in LaTeX. Its core is a set of TikZ style definitions. It uses some of the last TikZ features, so a recent version of pgf is required (>=3.0). This version is shipped in most 2014 LaTeX version; you can check your version by typesetting a document that contains \pgfversion. +This material is subject to the LATEX Project Public License. + +The documentation and sty can be generated manually, by running tex on bondgraphs.ins and (pdf)latex on bondgraphs.dtx, or making use of the supplied Makefile.
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/bondgraphs/bondgraphs.pdf b/Master/texmf-dist/doc/latex/bondgraphs/bondgraphs.pdf Binary files differnew file mode 100644 index 00000000000..b05e176afb3 --- /dev/null +++ b/Master/texmf-dist/doc/latex/bondgraphs/bondgraphs.pdf diff --git a/Master/texmf-dist/source/latex/bondgraphs/bondgraphs.dtx b/Master/texmf-dist/source/latex/bondgraphs/bondgraphs.dtx new file mode 100644 index 00000000000..84ff435c33a --- /dev/null +++ b/Master/texmf-dist/source/latex/bondgraphs/bondgraphs.dtx @@ -0,0 +1,851 @@ +% \iffalse meta-comment +% +% Copyright (C) ⟨2014⟩ by ⟨Geert Folkertsma⟩ +% +% This file may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either +% version 1.2 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.2 or later is part of all distributions of +% LaTeX version 1999/12/01 or later. +% +% \fi +% +% +% \iffalse +%<*driver> +\ProvidesFile{bondgraphs.dtx} +\documentclass{ltxdoc} +\usepackage{bondgraphs} +\usetikzlibrary{circuits.ee.IEC,decorations,decorations.pathmorphing} +\tikzstyle{mass}=[minimum width=.7cm,minimum height=.7cm,draw=black!80!white,thick,fill=black!20!white] +\tikzstyle{spring}=[thick,decorate,decoration={zigzag,pre length=0.1cm,post length=0.1cm,segment length=5}] +\tikzstyle{world}=[minimum width=1.5cm, minimum height=5mm,fill,draw,thick] +\usepackage[numbered]{hypdoc} +\usepackage{xspace} +\usepackage{booktabs} +\usepackage{microtype} +\usepackage{amsmath} +\def\bgs{\textsf{bondgraphs}\xspace} +\def\bgspkg{\textsf{bondgraphs} package\xspace} +\def\tkz{\textsf{TikZ}\xspace} +\def\secref#1{\hyperref[#1]{Section~\ref*{#1}: \nameref*{#1}}} +\def\figref#1{\hyperref[#1]{Figure~\ref*{#1}}} +\def\bgsrccolor{blue!40!black} +\def\bgsrc{\textbf{\color{\bgsrccolor}Source: }} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\begin{document} +\DocInput{bondgraphs.dtx} +\end{document} +%</driver> +% \fi +% +% \CheckSum{122} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% \changes{v0.9}{2014/11/20}{Initial .dtx version} +% \changes{v1.0}{2014/11/27}{Documentation completed.} +% +% \GetFileInfo{bondgraphs.sty} +% +% \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ } +% \DoNotIndex{\if,\else,\fi,\def,\ifcase,\or} +% \DoNotIndex{\tikzset,\pgfextra,\draw,\colorlet,\path,\node} +% \DoNotIndex{\pgfmathparse,\pgfdecoratedangle,\tikzinputsegmentfirst,\tikzinputsegmentlast} +% \DoNotIndex{\NeedsTeXFormat,\ProvidesPackage,\RequirePackage,\usetikzlibrary,\kvoptions,\SetupKeyvalOptions,\DeclareStringOption,\DeclareBoolOption,\DeclareComplementaryOption,\ProcessLocalKeyvalOptions} +% \DoNotIndex{\ifbondgraphs@grey,\message,\pgfmathresult,\ifbondgraphs@curly,\small,\newcommand,\tikz} +% \DoNotIndex{\bfseries,\mdseries,\mathbb,\bgroup,\egroup,\mdseries,\newif,\ifbondgraphs@bgelement@multiport,\ifbondgraphs@bgelement@wordbg,\pgfkeys} +% \DoNotIndex{\ifnum,\ensuremath,\mathbb,\textrm,\textbf,\newenvironment,\begin,\end} +% \DoNotIndex{\bondgraphs@bgelement@n,\bondgraphs@bondlabelcolour,\bondgraphs@labelcolour} +% +% \title{The \bgspkg{}\thanks{This document corresponds to \bgs{}~\fileversion, dated~\filedate.}} +% \author{Geert Folkertsma \\ \texttt{g.a.folkertsma@ieee.org}} +% +% \maketitle +% +% \begin{abstract} +% The bondgraphs package is used to draw bond graphs in LaTeX. It uses a recent version (3.0+) of TikZ for the drawing, hence, it is mainly a set of TikZ styles that makes the drawing of bond graphs easier. +% \end{abstract} +% +% \section{Introduction} +% A bond graph is a graphical representation of a physical dynamic system. The graph consists of nodes---junctions and elements---and edges---bonds---just like any other graph. This package, \bgs{}\footnote{From now on, we will write ``bondgraphs'' as a single word.}, is made to facilitate the drawing of bondgaphs in \LaTeX. For more information about bondgraphs, we suggest the original introduction by Henry Paynter (``Analysis and Design of Engineering Systems,'' ISBN~0-262-16004-8) or the PhD thesis ``Physical systems theory in terms of bond graphs'' by P.C. Breedveld, ISBN~90-9000599-4. +% +% \emph{\color{red!50!black}Note that this package relies on a very recent version of \tkz{}/pgf, namely 3.0. This version is shipped with recent (2014+) versions of \LaTeX{}.} +% +% To conclude this introduction, \figref{fig:analogies} shows two analogous physical systems and the corresponding bondgraph. +% +% \begin{figure}[h!] +% \centering +% \begin{bondgraph} +% \node at (0,0) (one) {1}; +% \node[left=1 of one,label={west:$u:$}] (Se) {Se}; +% \node[above=1 of one] (I) {I}; +% \node[right=1 of one] (C) {C}; +% \draw +% (Se) edge[e_out] (one) +% (one) edge[e_out] (I) +% edge[f_out] (C); +% \end{bondgraph}\hfil\begin{tikzpicture}[circuit ee IEC] +% \draw (0,0) to[voltage source={direction info={volt=u}}] (0,2) +% to [inductor={info={$I=L$}}] (2,2) +% to [capacitor={info'={$C$}}] (2,0) +% to (0,0); +% \end{tikzpicture}\hfil\begin{tikzpicture} +% \node[mass] at (0,0) (m) {$I=m$}; +% \node[world,below=1 of m] (g) {}; +% \draw[spring] (m.south west)++(0.2,0) -- +(0,-1); +% \node at ($(m.south east)+(-0.2,-.5)$) (F) {$F$}; +% \node[right=-.2 of F] {$=u$}; +% \draw[latex-] (m.south east)++(-0.2,0) -- (F); +% \draw[-latex] (F) -- ($(m.south east)+(-0.2,-1)$); +% \node[left=.7 of F] {$C=\frac{1}{k}$}; +% \end{tikzpicture} +% \caption{Two analogous physical systems: in the electrical and mechanical domain; and the bondgraph that describes both.} +% \label{fig:analogies} +% \end{figure} +% \clearpage +% \section{Usage} +% The \bgspkg provides styles for complete bondgraph drawing, as well as text-mode commands to draw or typeset single bonds or elements, useful e.g. when explaining concepts or referring to elements in a complete bondgrahp. +% \subsection{Text-mode} +% +% \subsubsection{Bonds}\label{sec:textmode-bonds} +% \DescribeMacro{\bond} +% |\bond| \oarg{drawing options} \\ +% The |\bond| command draws a single bond from left to right, like so: \bond{}. +% The drawing options can be used to specify causality and various colours and labels, as demonstrated in the table below. Note: the |diff| and |error| are redefined to grey when using the package option |grey|. \\ +% \begin{tabular}{rllr} +% \textbf{Description} & ~ & \textbf{Option} & \textbf{Result} \\ \toprule +% Causality & effort in / flow out & |e_in| & \bond[e_in] \\ +% ~ & ~ & |f_out| & \bond[f_out] \\ +% ~ & effort out / flow in & |e_out| & \bond[e_out] \\ +% ~ & ~ & |f_in| & \bond[f_in] \\ \midrule +% Causal stroke & differential causality & |e_out={diff}| & \bond[e_out={diff}] \\ +% ~ & erroneous causality & |f_out={error}|& \bond[f_out={error}] \\ +% ~ & arbitrary colour & |f_in={blue} | & \bond[f_in={blue}] \\ \midrule +% Labels & effort & |effort={$F_2$}| & \bond[effort={$F_2$}] \\ +% ~ & flow & |flow={$v_2$}| & \bond[flow={$v_2$}] \\ +% ~ & both & |flow={f},effort={e}|&\bond[flow={f},effort={e}] \\ \midrule +% \multicolumn{2}{l}{Multi-dimensional bonds} & |mbond| & \bond[mbond] \\ +% \bottomrule +% \end{tabular}\\[12pt] +% Note that the bond label colour can be set with the |bondlabelcolour| package option, which is dark green by default, or grey when the |grey| package option is used. +% +% Any option that is not recognised as one of the options listed in the above table is passed on to the \tkz drawing command. This allows for example the colouring of a bond, or the changing of a causal stroke width\footnote{This is actually already used in the table, with the \texttt{f\_in={blue}} option}. A (rather extreme) example: \\[6pt] +% |\bond[green,ultra thick,e_in={line width=5pt,width=20pt,orange!60}]| \\ gives \bond[green,ultra thick,e_in={line width=5pt,width=12pt,orange!60}]. +% +% \clearpage +% \subsubsection{Elements} +% \DescribeMacro{\bgelement} +% |\bgelement| \oarg{options} \marg{element} \\ +% Like |\bond|, |\bgelement| typesets a single bondgraph element in text, which is most useful when referring to elements in a complete bondgraph drawing. In contrast to the |\bond| command, |\bgelement| does not use \tkz for drawing, but \LaTeX{} typesetting. The following table shows the various options: \\[6pt] +% \begin{tabular}{l l r c} +% \textbf{Element type} & \textbf{Extra options} & \textbf{Examples} & \textbf{Result} \\ \toprule +% Normal & -- & |\bgelement{R}| & \bgelement{R} \\ +% ~ & ~ & |\bgelement{1}| & \bgelement{1} \\ +% ~ & Multiport & |\bgelement[multiport]{C}| & \bgelement[multiport]{C} \\ +% ~ & ~ & |\bgelement[multiport]{MTF}|& \bgelement[multiport]{MTF} \\ +% ~ & $n$-dimensional & |\bgelement[n=3]{Se}| & \bgelement[n=3]{Se} \\ +% ~ & ~ & |\bgelement[n=1]{Gy}| & \bgelement[n=1]{Gy} \\ +% ~ & combination&|\bgelement[n=2,multiport]{I}|&\bgelement[n=2,multiport]{I} \\ \midrule +% Word-bondgraph & (none allowed) & |\bgelement[wordbg]{Sys}| & \bgelement[wordbg]{Sys} \\ +% \bottomrule +% \end{tabular} \\[12pt] +% Note that the word-bondgraph element is exception to the no-\tkz rule: it is drawn as an elliptical \tkz node, with argument \marg{element} passed as node contents. Hence, it is possible to do something like: \\[6pt] +% |\bgelement[wordbg]{\bgelement[n=4]{Environment}}|, \\ +% which gives +% \bgelement[wordbg]{\bgelement[n=4]{Environment}}. +% +% \clearpage +% \subsection{Drawing mode} +% While the text-mode commands have their uses, the most important part of this package is the drawing of actual bondgraphs. Because the drawing of bonds has been implemented using \tkz styles, the drawing of bondgraphs comes down to drawing nodes and connecting edges using \tkz. There are examples in the next section (\secref{sec:examples}); here only the basic structure is explained. +% +% Note that, because all drawing is done in \tkz, it is very easy to make use of \tkz{}'s advanced positioning features and other libraries. By default, the \tkz{}-libraries |shapes| and |positioning| are loaded; the example section demonstrates their use. +% +% \subsubsection{Bonds} +% Bonds are drawn using the |bond| style on a path or an edge. Because the text-mode |\bond| command actually draws an edge with the |bond| style appended to the optional \oarg{drawing options} (see \secref{sec:textmode-bonds}), all the options explained there are applicable in drawing mode, too. The example below shows how to draw bonds inside a |tikzpicture| environment: \\[6pt] +% \begin{tabular}{rl} +% \begin{minipage}{.7\columnwidth} +% \begin{verbatim} +% \begin{tikzpicture} +% \draw[bond] (0,0) -- (1,0); +% \draw (0,-.5) edge[bond,effort={e}] (1,-.5); +% \draw[bond,e_in={diff}] (0,-1) to (2,-1.5); +% \end{tikzpicture} +% \end{verbatim} +% \end{minipage} & \begin{minipage}{.3\columnwidth}\begin{tikzpicture} +% \draw[bond] (0,0) -- (1,0); +% \draw (0,-.5) edge[bond,effort={e}] (1,-.5); +% \draw[bond,e_in={diff}] (0,-1) to (1.5,-1.5); +% \end{tikzpicture}\end{minipage} +% \end{tabular}\\[12pt] +% +% \DescribeEnv{bonds} +% A special drawing style is defined, |bonds|, which appends the |bond| style to all |edge|s on the path. It is useful when drawing a lot of bonds in one go---just remember to use |edge| rather than |to| or |--| between nodes or coordinates:\\[6pt] +% \begin{tabular}{rl} +% \begin{minipage}{.7\columnwidth} +% \begin{verbatim} +% \begin{tikzpicture} +% \draw[bonds] +% (0,0) edge (1,0.3) +% edge (1,-0.3) +% (1,-1) edge (0,-1) +% (0,-1.5) -- (1,-1.5); %won't produce a bond +% \end{tikzpicture} +% \end{verbatim} +% \end{minipage} & \begin{minipage}{.3\columnwidth}\begin{tikzpicture} +% \draw[bonds] +% (0,0) edge (1,0.3) +% edge (1,-0.3) +% (1,-1) edge (0,-1) +% (0,-1.5) -- (1,-1.5); +% \end{tikzpicture}\end{minipage} +% \end{tabular}\\[12pt] +% Finally, a silly drawing that shows the half-arrow stroke always points down:\\[6pt] +% \begin{tabular}{rl} +% \begin{minipage}{.7\columnwidth} +% \begin{verbatim} +% \begin{tikzpicture} +% \foreach \a in {0,30,...,350} +% {\draw[bond] (0,0) -- (\a:1);} +% \end{tikzpicture} +% \end{verbatim} +% \end{minipage} & \begin{minipage}{.3\columnwidth} +% \begin{tikzpicture} +% \foreach \a in {0,30,...,350} +% {\draw[bond] (0,0) -- (\a:1);} +% \end{tikzpicture} +% \end{minipage} +% \end{tabular}\\[12pt] +% There are two more things to mention on the subject of bonds drawing: \begin{enumerate} +% \item the package option |curly| will change the straight half-arrow into a curly one; +% \item some people prefer the half-arrow stroke to point left or down; this can be tweaked at the top of the generated \texttt{.sty} file (see \secref{sec:implementation-bonds}), which \emph{might} become a package option in the future. +% \end{enumerate} +% +% \subsubsection{Elements} +% Elements and junctions are drawn as \tkz nodes, with the |bgelement| style. This style does two things: it typesets the label text in bold (|\bfseries|) and defines a special label style for element labelling. Some examples:\\[6pt] +% \begin{tabular}{rl} +% \begin{minipage}{.7\columnwidth} +% \begin{verbatim} +% \begin{tikzpicture} +% \node[bgelement] at (0,0) {C}; +% \node[bgelement] at (0,-0.5) {Se}; +% \end{tikzpicture} +% \end{verbatim} +% \end{minipage} & \begin{minipage}{.3\columnwidth} +% \begin{tikzpicture} +% \node[bgelement] at (0,0) {C}; +% \node[bgelement] at (0,-0.5) {Se}; +% \end{tikzpicture} +% \end{minipage} \\ +% \begin{minipage}{.7\columnwidth} +% \begin{verbatim} +% \begin{tikzpicture} +% \node[bgelement,label=east:$v_x$] at (0,0) {1}; +% \node[bgelement,label=south:m] at (0,-0.5) {I}; +% \end{tikzpicture} +% \end{verbatim} +% \end{minipage} & \begin{minipage}{.3\columnwidth} +% \begin{tikzpicture} +% \node[bgelement,label=east:$v_x$] at (0,0) {1}; +% \node[bgelement,label=south:m] at (0,-0.5) {I}; +% \end{tikzpicture} +% \end{minipage} \\ +% \end{tabular}\\[12pt] +% Note that the element label colour can be set with the |labelcolour| package option, which is blue by default, or grey when the |grey| package option is used. +% +% \emph{\bfseries\color{red!70!black}Important note:} the |bgelement| \tkz style is \emph{not} the same as the |\bgelement| text-mode macro. There \emph{is} a |multiport| option/style that works by a lucky stroke, typesetting the node text in blackboard bold font, but it is recommended to instead use the |\bgelement| macro inside the node text for more advanced elements:\\[6pt] +% |\tikz \node {\bgelement[multiport,n=2]{RS}} ;| gives \tikz[baseline=(the_elm.base)] \node (the_elm) {\bgelement[multiport,n=2]{RS}} ; +% +% \clearpage +% \subsection{The \texttt{bondgraph} environment} +% \DescribeEnv{bondgraph} +% The \bgspkg currently defines only one environment: the |bondgraph| environment. It is actually an alias for the |tikzpicture| environment, with two convenient options passed to it automatically: \begin{enumerate} +% \item every node gets the style |bgelement|; +% \item every edge gets the style |bond| appended to it. +% \end{enumerate} +% Any options passed to the |bondgraph| environment are passed along to the |tikzpicture| environment. Note that while this environment is a convenient shorthand to quickly draw bondgraphs, the fact that the styles get appended to \emph{every} node and edge mean that it is only suitable for pure bondgraphs---no signal lines, no block diagrams, et cetera, since they would be warped by the bondgraph-specific styles. \\[12pt] +% \begin{tabular}{rl} +% \begin{minipage}{.7\textwidth} +% \begin{verbatim} +% \begin{bondgraph} +% \node (Se) {Se}; +% \node[right=1 of Se] (R) {R}; +% %use `edge': `to' or `--' has no bond style +% \draw (Se) edge (R); +% \end{bondgraph} +% \end{verbatim} +% \end{minipage} & \begin{minipage}{.3\textwidth} +% \begin{bondgraph} +% \node (Se) {Se}; +% \node[right=1 of Se] (R) {R}; +% \draw (Se) edge (R); +% \end{bondgraph} +% \end{minipage} +% \end{tabular} +% +% \clearpage +% \section{Examples}\label{sec:examples} +% This section contains some basic and more advanced examples of the \bgspkg usage. +% +% \subsection{Various bonds} +% Example picture, showing bonds from and to several nodes, using the \texttt{bond} style and causality (\texttt{\{e,f\}\_\{in,out\}}) options, including bond colours and causal stroke colours: +% +% \begin{tikzpicture} +% \node (a) at (0,0) {a}; +% \node (b) at (1,0) {b}; +% \node (c) at (1,1) {c}; +% \node (d) at (2,0) {d}; +% \node (e) at (1,-1) {e}; +% \node (f) at (2,0.9) {f}; +% +% \draw[bond,e_in] (a) -- (b); +% \draw[bond,e_out] (b) -- (c); +% \draw[bond,e_out={diff}] (d) -- (b); +% \draw[bond,red,f_out={blue}] (b) -- (e); +% \draw[mbond] (b) -- (f); +% \end{tikzpicture}\\ +% \bgsrc{} +% {\color{\bgsrccolor}\begin{verbatim} +% \begin{tikzpicture} +% \node (a) at (0,0) {a}; +% \node (b) at (1,0) {b}; +% \node (c) at (1,1) {c}; +% \node (d) at (2,0) {d}; +% \node (e) at (1,-1) {e}; +% \node (f) at (2,0.9) {f}; +% +% \draw[bond,e_in] (a) -- (b); +% \draw[bond,e_out] (b) -- (c); +% \draw[bond,e_out={diff}] (d) -- (b); +% \draw[bond,red,f_out={blue}] (b) -- (e); +% \draw[mbond] (b) -- (f); +% \end{tikzpicture} +% \end{verbatim}} +% +% \subsection{bgelement nodes} +% Example showing the |bgelement| node style and again bonds between them: +% +% \begin{tikzpicture} +% \node[bgelement] (Se) at (0,0) {Se}; +% \node[bgelement] (one) at (2,0) {1}; +% \node[bgelement] (C) at (4,0) {C}; +% +% \draw[bond,f_in] (Se) -- (one); +% \draw[f_in={orange},bond] (one) -- (C); +% \end{tikzpicture}\\ +% \bgsrc{} +% {\color{\bgsrccolor}\begin{verbatim} +% \begin{tikzpicture} +% \node[bgelement] (Se) at (0,0) {Se}; +% \node[bgelement] (one) at (2,0) {1}; +% \node[bgelement] (C) at (4,0) {C}; +% +% \draw[bond,f_in] (Se) -- (one); +% \draw[f_in={orange},bond] (one) -- (C); +% \end{tikzpicture} +% \end{verbatim}} +% +% \subsection{Large motor model} +% +% Large motor model, with a scope that sets the |bgelement| style for each node; and uses a short-hand |edge| for all the bonds, with the |bonds| style that sets the |bond| style for each edge. Uses the |positioning| \tkz{}-library. +% +% \begin{tikzpicture}[scale=0.7] +% \begin{scope}[every node/.style={bgelement}] +% \node (Se) at (0,0) {Se}; +% \node[right=1 of Se] (i) {1}; +% \node[above=1 of i] (Iel) {I}; +% \node[below=1 of i] (Rel) {R}; +% \node[right=1 of i] (GY) {GY}; +% \node[right=1 of GY] (w) {1}; +% \node[above=1 of w] (Im) {I}; +% \node[below=1 of w] (Rm) {R}; +% \node[right=1 of w] (TF) {TF}; +% \node[right=1 of TF] (ww) {1}; +% \node[above=1 of ww,multiport] (Iw) {I}; +% \end{scope} +% +% \draw[bonds] +% (Se) edge [e_out] (i) +% (i) edge [e_in] (Iel) +% edge [e_in] (Rel) +% edge [e_in] (GY) +% (GY) edge [e_out] (w) +% (w) edge [e_out] (Im) +% edge [e_in] (Rm) +% edge [e_in] (TF) +% (TF) edge [mbond,e_in] (ww) +% (ww) edge [mbond,e_in={diff}] (Iw); +% \end{tikzpicture}\\ +% \bgsrc{} +% {\color{\bgsrccolor}\begin{verbatim} +% \begin{tikzpicture}[scale=0.7] +% \begin{scope}[every node/.style={bgelement}] +% \node (Se) at (0,0) {Se}; +% \node[right=1 of Se] (i) {1}; +% \node[above=1 of i] (Iel) {I}; +% \node[below=1 of i] (Rel) {R}; +% \node[right=1 of i] (GY) {GY}; +% \node[right=1 of GY] (w) {1}; +% \node[above=1 of w] (Im) {I}; +% \node[below=1 of w] (Rm) {R}; +% \node[right=1 of w] (TF) {TF}; +% \node[right=1 of TF] (ww) {1}; +% \node[above=1 of ww,multiport] (Iw) {I}; +% \end{scope} +% +% \draw[bonds] +% (Se) edge [e_out] (i) +% (i) edge [e_in] (Iel) +% edge [e_in] (Rel) +% edge [e_in] (GY) +% (GY) edge [e_out] (w) +% (w) edge [e_out] (Im) +% edge [e_in] (Rm) +% edge [e_in] (TF) +% (TF) edge [mbond,e_in] (ww) +% (ww) edge [mbond,e_in={diff}] (Iw); +% \end{tikzpicture} +% \end{verbatim}} +% +% \clearpage +% \subsection{\texttt{bondgraph} environment} +% +% Example of the same bondgraph, twice: once manually with a \texttt{tikzpicture} environment and the \texttt{every node/.style={bgelement}}; \texttt{every edge/.append style={bond}}; once with the \texttt{bondgraph} environment that is an alias for tikzpicture but sets these styles. +% +% \begin{tikzpicture}[every node/.style={bgelement},every edge/.append style={bond}] +% \node[label=left:$u$] at (0,0) (Se) {Se}; +% \node[label=below:$i$,right=1 of Se] (i) {1}; +% \node[label=right:L,above=1 of i] (L) {I}; +% \node[label=right:\textit{C},right=1 of i] (C) {C}; +% +% \draw +% (Se) edge[e_out] (i) +% (i) edge[e_out] (L) +% edge[f_out] (C); +% \end{tikzpicture}\\ +% \bgsrc{} +% {\color{\bgsrccolor}\begin{verbatim} +% \begin{tikzpicture}[every node/.style={bgelement},every edge/.append style={bond}] +% \node[label=left:$u$] at (0,0) (Se) {Se}; +% \node[label=below:$i$,right=1 of Se] (i) {1}; +% \node[label=right:L,above=1 of i] (L) {I}; +% \node[label=right:\textit{C},right=1 of i] (C) {C}; +% +% \draw +% (Se) edge[e_out] (i) +% (i) edge[e_out] (L) +% edge[f_out] (C); +% \end{tikzpicture} +% \end{verbatim}} +% +% \vskip4pt\hfil\rule{.5\textwidth}{.4pt}\hfil\vskip4pt +% +% \begin{bondgraph} +% \node[label=left:$u$] at (0,0) (Se) {Se}; +% \node[label=below:$i$,right=1 of Se] (i) {1}; +% \node[label=right:L,above=1 of i] (L) {I}; +% \node[label=right:\textit{C},right=1 of i] (C) {C}; +% +% \draw +% (Se) edge[e_out] (i) +% (i) edge[e_out] (L) +% edge[f_out] (C); +% \end{bondgraph}\\ +% \bgsrc{} +% {\color{\bgsrccolor}\begin{verbatim} +% \begin{bondgraph} +% \node[label=left:$u$] at (0,0) (Se) {Se}; +% \node[label=below:$i$,right=1 of Se] (i) {1}; +% \node[label=right:L,above=1 of i] (L) {I}; +% \node[label=right:\textit{C},right=1 of i] (C) {C}; +% +% \draw +% (Se) edge[e_out] (i) +% (i) edge[e_out] (L) +% edge[f_out] (C); +% \end{bondgraph} +% \end{verbatim}} +% +% \subsection{Bondgraph in text} +% +% Bondgraph in a line of text looks like this: \begin{bondgraph}[baseline=(Se.base)] +% \node(Se){Se}; +% \node[right=1 of Se] (C) {C}; +% \draw (Se) edge[e_out={orange}] (C); +% \end{bondgraph} and here the sentence continues. Notice the use of \tkz{}'s |baseline| option to align the text with the baseline of the \bgelement{Se}-element. \\[6pt] +% \bgsrc{} +% {\color{\bgsrccolor}\begin{verbatim} +% Bondgraph in a line of text looks like this: \begin{bondgraph}[baseline=(Se.base)] +% \node(Se){Se}; +% \node[right=1 of Se] (C) {C}; +% \draw (Se) edge[e_out={orange}] (C); +% \end{bondgraph} and here the sentence continues. +% Notice the use of \tkz{}'s |baseline| option to align the text with +% the baseline of the \bgelement{Se}-element. +% \end{verbatim}} +% \subsection{Bondgaphs mixed with block diagrams} +% This is a drawing of a simple mechanical system (a force actuator on a mass), where the flow is integrated to find the position, which is then used as input for a PD-controller. +% +% \tikzstyle{block}=[minimum width=7mm,minimum height=7mm,draw,thick] +% \tikzstyle{plusminus}=[circle,thick,draw,inner sep=0pt,minimum size=3mm] +% \tikzstyle{splitter}=[circle,fill,minimum size=2mm,inner sep=0pt] +% \tikzstyle{signal} = [-latex, color=red!30!black] +% \begin{tikzpicture} +% \begin{scope}[every node/.style={bgelement}] +% \node (one) {1}; +% \node[left=1 of one] (MSe) {MSe}; +% \node[right=1 of one] (I) {I}; +% \end{scope} +% \draw[bonds] +% (MSe) edge [e_out] (one) +% (one) edge [e_out] (I); +% +% \node[block,below=.5 of one] (int) {$\int$}; +% +% \node[plusminus,left=2 of MSe] (pp) {}; +% \node[block,left=.5 of pp] (K) {K$_\text{P}$}; +% \node[splitter,left=2 of K] (split) {}; +% \node[block,above=.5 of K] (D) {K$_\text{D}$}; +% \node[block,left=.5 of D] (ddt) {\small $\frac{\mbox{d}}{\mbox{d}t}$}; +% \node[plusminus,left=.5 of split] (pm) {}; +% \node[block,left=.5 of pm] (setpoint) {0}; +% +% \begin{scope}[every path/.style={signal}] +% \draw (setpoint) -- node[near end,above]{$+$} (pm); +% \draw (pm) -- (split); +% \draw (split) |- (ddt); +% \draw (ddt) -- (D); +% \draw (D) -| node[pos=.9,right]{\small $+$} (pp); +% \draw (split) -- (K); +% \draw (K) -- node[near end,above]{\small $+$} (pp); +% \draw (pp) -- node[below]{$F$} (MSe); +% \draw (one) -- (int); +% \draw (int) -| node[pos=0.05,below]{$q$} node[pos=.96,left]{\small $-$} (pm); +% \end{scope} +% \end{tikzpicture} +% +% \bgsrc{} +% {\color{\bgsrccolor} +% \begin{verbatim} +% \tikzstyle{block}=[minimum width=7mm,minimum height=7mm,draw,thick] +% \tikzstyle{plusminus}=[circle,thick,draw,inner sep=0pt,minimum size=3mm] +% \tikzstyle{splitter}=[circle,fill,minimum size=2mm,inner sep=0pt] +% \tikzstyle{signal} = [-latex, color=red!30!black] +% \begin{tikzpicture} +% % The bond graph of a mechanical system +% \begin{scope}[every node/.style={bgelement}] +% \node (one) {1}; +% \node[left=1 of one] (MSe) {MSe}; +% \node[right=1 of one] (I) {I}; +% \end{scope} +% \draw[bonds] +% (MSe) edge [e_out] (one) +% (one) edge [e_out] (I); +% +% % Position sensor integrator +% \node[block,below=.5 of one] (int) {$\int$}; +% +% % The controller +% \node[plusminus,left=2 of MSe] (pp) {}; +% \node[block,left=.5 of pp] (K) {K$_\text{P}$}; +% \node[splitter,left=2 of K] (split) {}; +% \node[block,above=.5 of K] (D) {K$_\text{D}$}; +% \node[block,left=.5 of D] (ddt) {\small $\frac{\mbox{d}}{\mbox{d}t}$}; +% \node[plusminus,left=.5 of split] (pm) {}; +% \node[block,left=.5 of pm] (setpoint) {0}; +% +% % Draw all signals +% \begin{scope}[every path/.style={signal}] +% \draw (setpoint) -- node[near end,above]{$+$} (pm); +% \draw (pm) -- (split); +% \draw (split) |- (ddt); +% \draw (ddt) -- (D); +% \draw (D) -| node[pos=.9,right]{\small $+$} (pp); +% \draw (split) -- (K); +% \draw (K) -- node[near end,above]{\small $+$} (pp); +% \draw (pp) -- node[below]{$F$} (MSe); +% % The position signal +% \draw (one) -- (int); +% \draw (int) -| node[pos=0.05,below]{$q$} node[pos=.96,left]{\small $-$} (pm); +% \end{scope} +% \end{tikzpicture} +% \end{verbatim}} +% +% +% +% \StopEventually{\PrintChanges \PrintIndex} +% +% \clearpage +% \section{Implementation} +% +% \subsection{Dependencies} +% The package heavily relies on \tkz, but also uses some special fonts to typeset bondgraph elements. Note that \bgs{} uses \textsf{kvoptions} to process package options; that dependency is listed below under \secref{sec:implementation-options}. +% \begin{macrocode} +%<*package> +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{bondgraphs}[2014/11/27 v1.0 TikZ-based Bond graphs formatting package] +% \end{macrocode} +% \begin{macro}{TikZ} +% \tkz does all the drawing for the \bgspkg{}, using a number of libraries: the bond half-arrow is from |arrows|/|arrows.meta| and is drawn using |pathreplacing|; |positioning| isn't really required, but very useful when aligning bondgraph elements; |shapes| is used for the ellipse around word-bondgraph elements. +% \begin{macrocode} +\RequirePackage{tikz}[2013/12/13] +\usetikzlibrary{arrows,arrows.meta,decorations.pathreplacing} +\usetikzlibrary{positioning} +\usetikzlibrary{shapes} +% \end{macrocode} +% As mentioned, \textsf{amsfonts} is used for the mathbb font (multi-port elements) and \textsf{bm} is used to typeset bold math (bold mathbb symbols). +% \begin{macrocode} +\RequirePackage{amsfonts} +\RequirePackage{bm} +% \end{macrocode} +% \end{macro} +% \subsection{Options}\label{sec:implementation-options} +% \begin{macro}{kvoptions} +% The \textsf{kvoptions} package is used to parse package options. +% \begin{macrocode} +\RequirePackage{kvoptions} +\SetupKeyvalOptions{family=bondgraphs,prefix=bondgraphs@} +\DeclareStringOption[blue]{labelcolour} +\DeclareStringOption[green!50!black]{bondlabelcolour} +\DeclareBoolOption[false]{grey} +\DeclareComplementaryOption{colour}{grey} +% Options for the bond drawing +% TODO: curly on double line (multibond) are longer +\DeclareBoolOption[false]{curly} +\ProcessLocalKeyvalOptions{bondgraphs} +% \end{macrocode} +% \end{macro} +% \begin{macro}{colours} +% The \bgspkg{} uses colours for labels on bonds and elements, and also to allow the user to easily indicate a differential or erroneous causality, by colouring the causal stroke. Package option ``grey'' overrides all these colours to grey. +% \begin{macrocode} +\ifbondgraphs@grey + \message{Bondgraphs package: greyscale set} + \colorlet{diff}{black!60!white} + \colorlet{error}{black!40!white} + \def\bondgraphs@labelcolour{black!50!white} + \def\bondgraphs@bondlabelcolour{black!50!white} + %TODO: would be nice to have this as a style instead of a colour... +\else + \message{Bondgraphs package: using colour} + \colorlet{diff}{orange} + \colorlet{error}{red} +\fi +% \end{macrocode} +% \end{macro} +% \subsection{Bonds}\label{sec:implementation-bonds} +% \begin{macro}{bonds} +% All bonds are drawn as a (straight or curly) half-arrow with TikZ. The switch/case statement makes sure that the half-arrow stroke always points down (credits to Mark Wibrow at \url{http://tex.stackexchange.com/questions/208313/tikz-pgf-half-arrow-stroke-always-down-left}). This orientation can be changed to make the stroke always go left or down, never right, by changing the |-1| in |\pgfdecoratedangle-1| to a |+45|. TODO: make this a package option. The argument to this TikZ stile is passed to the draw command, to allow different colour/line width/etc. +% \begin{macrocode} +\tikzset{bond/.style args={#1}{ + thick, + decoration={show path construction, + lineto code={ + \draw[#1,shorten <=1pt] + \pgfextra{% +45 i.s.o. -1 for to left or to under, always + \pgfmathparse{int((\pgfdecoratedangle-1)/90)} + \ifcase\pgfmathresult + \ifbondgraphs@curly + \tikzset{-{Classical TikZ Rightarrow[length=3 2 0.8,right]}} + \else + \tikzset{-{Straight Barb[length=3 2 0.8,right]}} + \fi + \or + \ifbondgraphs@curly + \tikzset{-{Classical TikZ Rightarrow[length=3 2 0.8,left]}} + \else + \tikzset{-{Straight Barb[length=3 2 0.8,left]}} + \fi + \or + \ifbondgraphs@curly + \tikzset{-{Classical TikZ Rightarrow[length=3 2 0.8,left]}} + \else + \tikzset{-{Straight Barb[length=3 2 0.8,left]}} + \fi + \else + \ifbondgraphs@curly + \tikzset{-{Classical TikZ Rightarrow[length=3 2 0.8,right]}} + \else + \tikzset{-{Straight Barb[length=3 2 0.8,right]}} + \fi + \fi + } (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast); + } + }, + postaction=decorate +}, +bond/.default={} +} +% \end{macrocode} +% \begin{macro}{mbond} +% A multi-bond is simply a bond with a double draw, and lengthened a bit for better-looking result +% \begin{macrocode} +\tikzset{mbond/.style={bond={double,shorten >=-1pt}}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{draw[bonds]} +% Convenience function (style) to draw lots of bonds, using |\draw[bonds]| +% \begin{macrocode} +\tikzset{bonds/.style={every edge/.append style={bond}}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{bond labels} +% Provide labelling for effort (above) and flow (below) the bond. +% TODO: What happens when bond is vertical? +% \begin{macrocode} +\tikzset{ + bondlabel/.style={ + font=\small, + color=\bondgraphs@bondlabelcolour + }, + effort/.style args={#1}{ + edge node={node [bondlabel,above]{#1}} + }, + effort/.default={}, + flow/.style args={#1}{ + edge node={node [bondlabel,below]{#1}} + }, + flow/.default={} +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{causality} +% The causal stroke of bonds is drawn as a thick line at the end, or start, of the bond. |e_in| / |f_out| and |f_in| / |e_out| are aliases. The optional argument gets passed on to the draw command of the stroke, e.g. to set its colour. +% \begin{macrocode} +\tikzset{ + e_out/.style args={#1}{ + -{|[line width=1.2pt,width=7pt,#1]} + }, + e_out/.default={black}, + f_in/.style args={#1}{ + e_out={#1} + }, + e_in/.style args={#1}{ + {|[line width=1.2pt,width=7pt,#1]}- + }, + e_in/.default={black}, + f_out/.style args={#1}{ + e_in={#1} + } +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{bond} +% A simple command to place a bond in text. Simply draw a bond from |(0,0)| to |(1,0)|, passing on any options to the edge. +% \begin{macrocode} +\newcommand\bond[1][]{% + \tikz \draw(0,0) edge[bond,#1] (1,0); +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \subsection{Elements}\label{sec:implementation-elements} +% \begin{macro}{elements} +% Bondgraph elements in TikZ are typeset in bold. It would be nicer to pass the node text through the |\bgelement| macro that is used for typesetting bondgraph elements in text (see below), but that's not easy. Possibly work around this by using |node contents| instead, as per \url{http://tex.stackexchange.com/questions/209175/filter-tikz-node-text-through-macro}. +% \begin{macrocode} +\tikzset{ + bgelement/.style={ + font=\bfseries, + prefix after command= {\pgfextra{ + \tikzset{every label/.style={ + % Element label style + \bondgraphs@labelcolour, + font={\mdseries} + } + }}} + } +} +% \end{macrocode} +% Multiport elements are typeset with the mathbb font. The |\bgroup| and |\egroup| actually do nothing and this construction only works by coincidence as explained by egreg in the aforementioned tex.stackexchange topic. TODO: fix this. +% \begin{macrocode} +\tikzset{ + multiport/.style={ + execute at begin node=$\mathbb\bgroup, + execute at end node=\egroup$ + } +} +% \end{macrocode} +% Word-bg elements: ellipse with text inside +% \begin{macrocode} +\tikzset{ + wordbgelement/.style={ + draw,ellipse,minimum size=12pt,thick,font=\mdseries + } +} +% \end{macrocode} +% \begin{macro}{bgelement} +% Bondgraph elements in text are typeset much more robustly. |\pgfkeys| is used to parse all options. Currently: |multiport| to typeset in blackboard bold font; |n=x| to add a subscript |x| to indicate n-dimensional elements. +% \begin{macrocode} +% Must create the if for multiport and wordbg outside of pgfkeys +\newif\ifbondgraphs@bgelement@multiport +\newif\ifbondgraphs@bgelement@wordbg +\pgfkeys{ + /bgelement/.is family, %automatically cd to /bgelement when present + /bgelement/n/.store in=\bondgraphs@bgelement@n, + /bgelement/n=1, + % + /bgelement/multiport/.is if=bondgraphs@bgelement@multiport, + /bgelement/multiport=false, + /bgelement/wordbg/.is if=bondgraphs@bgelement@wordbg, + /bgelement/wordbg=false, +} +\newcommand\bgelement[2][]{% + \pgfkeys{/bgelement,multiport=false,wordbg=false,#1}% + \ifbondgraphs@bgelement@wordbg +% \end{macrocode} +% Word-bg elements have an ellipse around them and hence are drawn with inline \tkz. +% \begin{macrocode} + \tikz[baseline=(the_elm.base)] \node[wordbgelement] (the_elm) {#2};% + \else + \ifbondgraphs@bgelement@multiport + \ifnum\bondgraphs@bgelement@n=1 + \ensuremath{\mathbb{#2}}% + \else + \ensuremath{\mathbb{#2}_{\bondgraphs@bgelement@n}}% + \fi + \else + \ifnum\bondgraphs@bgelement@n=1 + \textrm{\textbf{#2}}% + \else + \textrm{\textbf{#2}$_{\bondgraphs@bgelement@n}$}% + \fi + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \subsection{Environments}\label{sec:implementation-environments} +% \begin{environment}{bondgraph} +% When drawing pure bondgraphs, it is convenient to use the |bondgraph| environment, which is an alias for tikzpicture but with the proper styles set for nodes and edges. +% \begin{macrocode} +\newenvironment{bondgraph}[1][]{% +\begin{tikzpicture}% + [#1,every node/.style={bgelement},every edge/.append style={bond}]% +}{% +\end{tikzpicture} +} +%</package> +% \end{macrocode} +% \end{environment} +% \Finale +\endinput
\ No newline at end of file diff --git a/Master/texmf-dist/source/latex/bondgraphs/bondgraphs.ins b/Master/texmf-dist/source/latex/bondgraphs/bondgraphs.ins new file mode 100644 index 00000000000..72ba95f8cc0 --- /dev/null +++ b/Master/texmf-dist/source/latex/bondgraphs/bondgraphs.ins @@ -0,0 +1,57 @@ +%% +%% Copyright (C) ⟨2014⟩ by ⟨Geert Folkertsma⟩ +%% +%% This file 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 2008/05/04 or later. +%% + +% Docstrip parses the documentation +\input docstrip.tex + +% Withhold info messages +\keepsilent + +% Install into this dir: +\usedir{tex/latex/bondgraphs} + +% Put this preamble at the top of every generated file: +\preamble +This is a generated file. + +Copyright (C) ⟨2014⟩ by ⟨Geert Folkertsma⟩ +This file 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 2008/05/04 or later. + +\endpreamble + +% This actually tells Docstrip which files to produce +\generate{\file{bondgraphs.sty}{\from{bondgraphs.dtx}{package}}} + + +\obeyspaces +\Msg{****************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the *} +\Msg{* following file into a directory searched by TeX: *} +\Msg{* *} +\Msg{* bondgraphs.sty *} +\Msg{* *} +\Msg{* To produce the documentation, run the file *} +\Msg{* bondgraphs.dtx through LaTeX. *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} \Msg{****************************************************} + +\endbatchfile
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/bondgraphs/bondgraphs.sty b/Master/texmf-dist/tex/latex/bondgraphs/bondgraphs.sty new file mode 100644 index 00000000000..69c464cebba --- /dev/null +++ b/Master/texmf-dist/tex/latex/bondgraphs/bondgraphs.sty @@ -0,0 +1,184 @@ +%% +%% This is file `bondgraphs.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bondgraphs.dtx (with options: `package') +%% This is a generated file. +%% +%% Copyright (C) ⟨2014⟩ by ⟨Geert Folkertsma⟩ +%% This file 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 2008/05/04 or later. +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{bondgraphs}[2014/11/27 v1.0 TikZ-based Bond graphs formatting package] +\RequirePackage{tikz}[2013/12/13] +\usetikzlibrary{arrows,arrows.meta,decorations.pathreplacing} +\usetikzlibrary{positioning} +\usetikzlibrary{shapes} +\RequirePackage{amsfonts} +\RequirePackage{bm} +\RequirePackage{kvoptions} +\SetupKeyvalOptions{family=bondgraphs,prefix=bondgraphs@} +\DeclareStringOption[blue]{labelcolour} +\DeclareStringOption[green!50!black]{bondlabelcolour} +\DeclareBoolOption[false]{grey} +\DeclareComplementaryOption{colour}{grey} +\DeclareBoolOption[false]{curly} +\ProcessLocalKeyvalOptions{bondgraphs} +\ifbondgraphs@grey + \message{Bondgraphs package: greyscale set} + \colorlet{diff}{black!60!white} + \colorlet{error}{black!40!white} + \def\bondgraphs@labelcolour{black!50!white} + \def\bondgraphs@bondlabelcolour{black!50!white} + %TODO: would be nice to have this as a style instead of a colour... +\else + \message{Bondgraphs package: using colour} + \colorlet{diff}{orange} + \colorlet{error}{red} +\fi +\tikzset{bond/.style args={#1}{ + thick, + decoration={show path construction, + lineto code={ + \draw[#1,shorten <=1pt] + \pgfextra{% +45 i.s.o. -1 for to left or to under, always + \pgfmathparse{int((\pgfdecoratedangle-1)/90)} + \ifcase\pgfmathresult + \ifbondgraphs@curly + \tikzset{-{Classical TikZ Rightarrow[length=3 2 0.8,right]}} + \else + \tikzset{-{Straight Barb[length=3 2 0.8,right]}} + \fi + \or + \ifbondgraphs@curly + \tikzset{-{Classical TikZ Rightarrow[length=3 2 0.8,left]}} + \else + \tikzset{-{Straight Barb[length=3 2 0.8,left]}} + \fi + \or + \ifbondgraphs@curly + \tikzset{-{Classical TikZ Rightarrow[length=3 2 0.8,left]}} + \else + \tikzset{-{Straight Barb[length=3 2 0.8,left]}} + \fi + \else + \ifbondgraphs@curly + \tikzset{-{Classical TikZ Rightarrow[length=3 2 0.8,right]}} + \else + \tikzset{-{Straight Barb[length=3 2 0.8,right]}} + \fi + \fi + } (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast); + } + }, + postaction=decorate +}, +bond/.default={} +} +\tikzset{mbond/.style={bond={double,shorten >=-1pt}}} +\tikzset{bonds/.style={every edge/.append style={bond}}} +\tikzset{ + bondlabel/.style={ + font=\small, + color=\bondgraphs@bondlabelcolour + }, + effort/.style args={#1}{ + edge node={node [bondlabel,above]{#1}} + }, + effort/.default={}, + flow/.style args={#1}{ + edge node={node [bondlabel,below]{#1}} + }, + flow/.default={} +} +\tikzset{ + e_out/.style args={#1}{ + -{|[line width=1.2pt,width=7pt,#1]} + }, + e_out/.default={black}, + f_in/.style args={#1}{ + e_out={#1} + }, + e_in/.style args={#1}{ + {|[line width=1.2pt,width=7pt,#1]}- + }, + e_in/.default={black}, + f_out/.style args={#1}{ + e_in={#1} + } +} +\newcommand\bond[1][]{% + \tikz \draw(0,0) edge[bond,#1] (1,0); +} +\tikzset{ + bgelement/.style={ + font=\bfseries, + prefix after command= {\pgfextra{ + \tikzset{every label/.style={ + % Element label style + \bondgraphs@labelcolour, + font={\mdseries} + } + }}} + } +} +\tikzset{ + multiport/.style={ + execute at begin node=$\mathbb\bgroup, + execute at end node=\egroup$ + } +} +\tikzset{ + wordbgelement/.style={ + draw,ellipse,minimum size=12pt,thick,font=\mdseries + } +} +\newif\ifbondgraphs@bgelement@multiport +\newif\ifbondgraphs@bgelement@wordbg +\pgfkeys{ + /bgelement/.is family, %automatically cd to /bgelement when present + /bgelement/n/.store in=\bondgraphs@bgelement@n, + /bgelement/n=1, + % + /bgelement/multiport/.is if=bondgraphs@bgelement@multiport, + /bgelement/multiport=false, + /bgelement/wordbg/.is if=bondgraphs@bgelement@wordbg, + /bgelement/wordbg=false, +} +\newcommand\bgelement[2][]{% + \pgfkeys{/bgelement,multiport=false,wordbg=false,#1}% + \ifbondgraphs@bgelement@wordbg + \tikz[baseline=(the_elm.base)] \node[wordbgelement] (the_elm) {#2};% + \else + \ifbondgraphs@bgelement@multiport + \ifnum\bondgraphs@bgelement@n=1 + \ensuremath{\mathbb{#2}}% + \else + \ensuremath{\mathbb{#2}_{\bondgraphs@bgelement@n}}% + \fi + \else + \ifnum\bondgraphs@bgelement@n=1 + \textrm{\textbf{#2}}% + \else + \textrm{\textbf{#2}$_{\bondgraphs@bgelement@n}$}% + \fi + \fi + \fi +} +\newenvironment{bondgraph}[1][]{% +\begin{tikzpicture}% + [#1,every node/.style={bgelement},every edge/.append style={bond}]% +}{% +\end{tikzpicture} +} +\endinput +%% +%% End of file `bondgraphs.sty'. diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 6e1107283c3..a945188ce9a 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -94,7 +94,7 @@ my @TLP_working = qw( bigfoot bigints binomexp biocon bitelist bizcard blacklettert1 blindtext blkarray block blockdraw_mp bloques blowup blox bnumexpr bodegraph bohr boisik bold-extra - boites boldtensors bondgraph bookest bookhands booklet + boites boldtensors bondgraph bondgraphs bookest bookhands booklet booktabs booktabs-de booktabs-fr boolexpr boondox bophook borceux bosisio boxedminipage boxhandler bpchem bpolynomial diff --git a/Master/tlpkg/tlpsrc/bondgraphs.tlpsrc b/Master/tlpkg/tlpsrc/bondgraphs.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/Master/tlpkg/tlpsrc/bondgraphs.tlpsrc diff --git a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc index 100b12414f8..5c910d61d38 100644 --- a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc @@ -14,6 +14,7 @@ depend bloques depend blox depend bodegraph depend bondgraph +depend bondgraphs depend braids depend bxeepic depend cachepic |