I would draw the isosceles trapezoid from the picture but I have a problem. Could you help me and write what I should write in latex?
[Tex/LaTex] Help to draw a trapezoid
tikz-pgf
Related Solutions
The braces, from decorations.pathreplacing
library, have an option mirror
, which reverses the face direction of the brace. So, that is all you should add to get it in the right direction. You can do it like this:
\documentclass[tikz,border=1mm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
% Die Grundlinie:
\draw(0,0)--(10,0);
% Striche und Beschriftung in Abständen 0, 2, 4, 6, ...
\foreach \x/\xtext in {0/$-m-n+1$,2/$-m-1$,4/$-m$,6/$0$,8/$m$,10/$m+n-1$}
\draw(\x,5pt)--(\x,-5pt) node[below] {\xtext};
% obere geschweifte Klammer mit Text darüber:
\draw[decorate, decoration={brace}, yshift=2ex] (0,0) -- node[above=0.4ex] {$0$'s} (2,0);
\draw[decorate, decoration={brace, mirror}, yshift=2ex] (10,0) -- node[above=0.4ex] {$l$'s and $0$'s with $l$'s separated by at least two $0$'s} (4,0);
\end{tikzpicture}
\end{document}
You've almost answered the question yourself, but you don't want to draw the outline of every node, just one. So you need to add draw
as an option to just that one node. To increase the size you can add e.g minimum size=1cm
as well, and add a color name if you want to change the color.
In the code below I've just added one line, indicated by the comment.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,calc}
\tikzset{
arro/.style={
->,
>=latex
},
bloque/.style={
draw,
minimum height=1cm,
minimum width=0.5cm
}
}
\begin{document}
\begin{tikzpicture}[]
\node[]
(input)
{Input};
\node[below=of input,label={left:$x_{1}$}]
(inputi)
{};
\node[below=of inputi,label={left:$x_{2}$}]
(inputii)
{};
\coordinate[below=of inputii] (aux);
\node[below=of aux,label={left:$x_{3}$}]
(inputiii)
{};
\node[below=of inputiii,label={left:$+1$}]
(inputiv)
{};
\node[right=of input]
(proje)
{Projection};
\node[circle,
draw,minimum size=1cm,orange, %% <-- these are added
label={above:\textsc{sum}}]
at (proje|-aux)
(projei)
{};
\node[right=of proje]
(out)
{Output};
\node[label={right:$h_{w,b}(x)$}]
at (out|-aux)
(outi)
{};
\foreach \Valor in {i,ii,iii,iv}
{
\draw[arro] (input\Valor) -- (projei);
}
\draw[arro] (projei) -- (outi);
\end{tikzpicture}
\end{document}
I would also suggest that you don't use label
for the input nodes on the left and the output node. With a couple of other minor changes:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,calc}
\tikzset{
arro/.style={
->,
>=latex
},
bloque/.style={
draw,
minimum height=1cm,
minimum width=0.5cm
}
}
\begin{document}
\begin{tikzpicture}[node distance=0.5cm and 1cm] % first value vertical distance, second horizontal
\node
(input)
{Input};
\node[below=of input]
(inputi)
{$x_{1}$};
\node[below=of inputi]
(inputii)
{$x_{2}$};
\coordinate[below=of inputii] (aux);
\node[below=of aux]
(inputiii)
{$x_{3}$};
\node[below=of inputiii]
(inputiv)
{$+1$};
\node[right=of input]
(proje)
{Projection};
\node[circle,
draw,minimum size=1cm,orange,
label={above:\textsc{sum}}]
at (proje|-aux)
(projei)
{};
\node[right=of proje]
(out)
{Output};
\node
at (out|-aux)
(outi)
{$h_{w,b}(x)$};
\foreach \Valor in {i,ii,iii,iv}
{
\draw[arro] (input\Valor) -- (projei);
}
\draw[arro] (projei) -- (outi);
\end{tikzpicture}
\end{document}
Best Answer
Something like this, perhaps?
EDIT
You asked about annotating the diagram. There are various tools for this. If we name our trapezium node with
(a)
, we can use the node anchors to place coordinates and draw dashd vertical lines in for the heightand little solid lines to mark the right angles
We can also name a couple more coordinates we need to mark further angles.
Loading the
angles
library, we can use itsangle
pic
to add some additional markingswhich use a common style for consistency,
my angle
, which we can define for thetikzpicture
environmentwith the following result
If you play around with the code and see what changes you can make and what does what, you will start to get a sense of how to modify it yourself and be in a better position to draw new diagrams or to modify existing examples, as well. Then you can ask specific, focused questions if you get stuck. The TikZ manual is large but very good. You don't need to read all of it! Instead, treat it as a reference and look up the things you need. The section covering TikZ's standard libraries, for example, includes a short section on
shapes.geometric
with full details of how to draw and modify trapezium-shaped nodes (among others) and the section on theangles
library explains how to draw in angles.Complete code: