You may use \tikzset
and \newcommand
to create the common code to put in your .cls
file.
For example I've created:
- a
myblue
style you can use instead of "very thick, blue"
- a
myhelp
command for the help lines
- a
whitepoint
and bluepoint
pic
s for the circles (filled white or blue, you may also create a unique pic
with a parameter to pass the color option)
- a
mylabels
command to add the labels.
See the code to know how to use them:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,shapes.symbols,positioning,decorations.pathmorphing}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% you may put a code like this in your .cls file
\tikzset{%
myblue/.style={blue, very thick},
pics/bluepoint/.style={code={%
\draw[very thick, blue, fill] (0,0) circle [radius=.08];
}},
pics/whitepoint/.style={code={%
\draw[very thick, blue, fill=white] (0,0) circle [radius = .08];
}},
}
\newcommand{\myhelp}{\draw[help lines] (\xmin, \ymin) grid (\xmax, \ymax);}
\newcommand{\mylabels}{%
\foreach \x in {1} \draw (0,\x)node[right]{\x};
\foreach \x in {1} \draw (\x,0)node[below]{\x};}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{tikzpicture}[scale=.9]
\def \xmin {-3}
\def \xmax {3}
\def \ymin {-2}
\def \ymax {3}
\myhelp
\draw [<->] (\xmin-.3,0) -- (\xmax+.3,0);
\draw [<->] (0,\ymin-.3) -- (0,\ymax+.3);
\node at (0,\ymax + .6) {$g(x)$};
\node at (\xmax + .6,0) {$x$};
\node at (-2, 1.5) {$y = g(x)$};
\draw[domain=-1.828:1, myblue, smooth] plot
({\x}, {-0.5*(\x-1)^2 + 2});
\draw[domain=1:2.732, myblue, smooth] plot
({\x}, {-1*(\x-1)^2 + 1});
\pic at (1,1) {bluepoint};
\pic at (1,2) {whitepoint};
\mylabels
\end{tikzpicture}
\end{document}
Of course the output is exactly the same:
If it could be useful, this is the version with a parametric option for color of the arrow tip, with blue
as default:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,shapes.symbols,positioning,decorations.pathmorphing}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% you may put a code like this in your .cls file
\tikzset{%
myblue/.style={blue, very thick},
pics/mypoint/.style={code={%
\draw[very thick, blue, fill=#1] (0,0) circle [radius=.08];
}},
pics/mypoint/.default=blue
}
\newcommand{\myhelp}{\draw[help lines] (\xmin, \ymin) grid (\xmax, \ymax);}
\newcommand{\mylabels}{%
\foreach \x in {1} \draw (0,\x)node[right]{\x};
\foreach \x in {1} \draw (\x,0)node[below]{\x};}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{tikzpicture}[scale=.9]
\def \xmin {-3}
\def \xmax {3}
\def \ymin {-2}
\def \ymax {3}
\myhelp
\draw [<->] (\xmin-.3,0) -- (\xmax+.3,0);
\draw [<->] (0,\ymin-.3) -- (0,\ymax+.3);
\node at (0,\ymax + .6) {$g(x)$};
\node at (\xmax + .6,0) {$x$};
\node at (-2, 1.5) {$y = g(x)$};
\draw[domain=-1.828:1, myblue, smooth] plot
({\x}, {-0.5*(\x-1)^2 + 2});
\draw[domain=1:2.732, myblue, smooth] plot
({\x}, {-1*(\x-1)^2 + 1});
\pic at (1,1) {mypoint};
\pic at (1,2) {mypoint=white};
\mylabels
\end{tikzpicture}
\end{document}
as starting point ...
\documentclass[tikz, margin=5pt]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[
TL/.style = {very thick, Bar[width=4mm]},% as Time Line :-)
tbox/.style = {font=\Large\bfseries\sffamily},
bbox/.style = {text width=4cm, align=left, inner sep=2mm}
]
\draw[TL] (-5,0) -- (5,0);
\draw[TL,densely dashed] (0,2mm) -- (0,-2mm);
%
\node [tbox,above] at (-2.4,0) {DAY (DM)};
\node [tbox,above] at ( 2.4,0) {NIGHT (CM)};
%
\node [bbox,below right] at (-5,0) {xx xx xx xxx xxx xxx xxx\\
yy yy yyy yyy yyyy\\
zzzzz zz zzzz z z zzz};
\node [bbox,below right] at (0,0) {xx xx xx xxx xxx xxx xxx\\
yy yy yyy yyy yyyy\\
zzzzz zz zzzz z z zzz};
\end{tikzpicture}
\end{document}
Edit: instead of >={Bar[width=4mm]}
is defined new style for vectors: Vect/.style = {very thick, Bar[width=4mm]}
and accordingly changed code for line.
Best Answer
As Martin commented you can use
[->]
in the\draw
command to add an arrow. Different arrow style can also be specified by using options such as:-stealth
,-latex
, etc.. Here are a few types:See Section 23 Arrow Tip Library for a list of the various ones that are already available. Adding
\usepgflibrary{arrows}
to your preamble provides a large variety of built in arrows.Since you included a
scope
in your example, it should be noted that you can also specify the arrow to be used for each line in ascope
as well by adding that to the options to\begin{scope}
. In the following all lines will have-stealth
arrows. Adding-
will disable the arrow for a particular line: