4

Could someone help me with a \tikzstyle for this trapezium block:

enter image description here

I tried but look how it looks like:

enter image description here

The main problem it is in how to set the text (0 1) in the right place.

The code I'm using to \tikzstyle and \node it is presented below:

\tikzstyle{mux} = [ trapezium,   draw,   
                    rotate = 270, trapezium angle = 60,  
                    minimum height = 1em,
                    inner ysep=10pt, outer sep=1pt, inner xsep=1pt, 
                    text width = 1em, 
                    node distance=3cm, text badly centered ]

 \node [mux, above of=sum1,align=center] (mux11)
                {\begin{large}\begin{sideways}0\end{sideways}\begin{sideways}\medskip 1\end{sideways}\end{large}};

I'm trying to draw a digital datapath so I'll use this block many times.

Torbjørn T.
  • 206,688
João
  • 191
  • 1
  • 11

2 Answers2

5

Instead of using sideways inside the node, you can just rotate the border of the shape instead. Further, with text width defined, the node contents will be flush left, so by removing text badly centered they end up at the right place. This also allows you to use \\ to add a line break. Last, don't use \large etc. as environments, you can specify the font size with font=\large in the style.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
  \tikzstyle{mux} = [ trapezium,   draw,   
                    shape border rotate = 270, trapezium angle = 60,  
                    inner ysep=0pt, outer sep=1pt, inner xsep=1pt, 
                    text width = 3em, 
                    node distance=3cm, font=\large ]

 \node [mux] {0\\1};
\end{tikzpicture}
\end{document}
Torbjørn T.
  • 206,688
5

Another way with Torbjørn's style but without \tikzstyle, in a slightly different syntax:

\begin{tikzpicture}[ mux/.style = {trapezium, draw,   
                     shape border rotate = 270, trapezium angle = 60,  
                     inner ysep = 0pt, outer sep = 1pt, inner xsep = 1pt, 
                     text width = 3em, node distance = 3cm, font = \large} ]
  \node [mux] {0\\1};
\end{tikzpicture}

And that syntax with the newer and recommended \tikzset:

\tikzset{ mux/.style = { trapezium, draw,   
                         shape border rotate = 270, trapezium angle = 60,  
                         inner ysep = 0pt, outer sep = 1pt, inner xsep  =1pt, 
                         text width = 3em, node distance = 3cm, font  =\large} }

See also: Should \tikzset or \tikzstyle be used to define TikZ styles?

Stefan Kottwitz
  • 231,401