diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/bondgraphs/bondgraphs.sty | 184 |
1 files changed, 184 insertions, 0 deletions
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'. |