Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How to write text inside of block, and the text must be consistent with normal text. The inside text font size is too smaller than normal e.g 11pt.

my source:

\begin{tikzpicture}
    \hspace*{-1.5in}
    \node  at (0,0) [draw,rectangle,minimum height=1.5cm,minimum width=3cm, align=left] (CP1){MA};
    \node  at (5,0) [draw,rectangle,minimum height=1.5cm,minimum width=3cm] (CP2){SC};
    \node  at (10,0) [draw,rectangle,minimum height=1.5cm,minimum width=3cm, align=left] (CP3){DC};
    \node  at (15,0) [draw,rectangle,minimum height=1.5cm,minimum width=3cm, text centered] (CP4){Switch};
    \draw [->, >=latex] (CP1) -- (CP2);
    \draw [->, >=latex] (CP2) -- (CP3);
    \draw [->, >=latex] (CP3) -- (CP4);
    \draw [->, >=latex] (CP4) -- (18.5,0);
    \draw (17.8,0)node[above]{Output};
    \draw [->, >=latex](-3.5,0.5) --(-1.5,0.5);
    \draw (-3,0.5)node[above]{C};
    \draw [->, >=latex](-3.5,-0.5) --(-1.5,-0.5);
    \draw (-2.7,-0.5)node[below]{M1};
\end{tikzpicture} 
share|improve this question
    
Use \begin{tikzpicture}\normalsize. –  Sigur Feb 1 at 18:29

2 Answers 2

In addtion to the comment by Sigur, your code still has room for improvement and I took the liberty to make some suggestions shown here. Basically, the suggestion moves (x,y) absolute coordinate method and, instead, uses positioning from tikzlibrary and right, above, below = of <reference> skills to place the nodes. Furthermore, this suggestion defines a style for every node (with text centered) so that the code is cleaner.

enter image description here

Code

\documentclass[11pt]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz,xcolor}
\usetikzlibrary{positioning,calc,arrows}

\begin{document}

You can change the font size inside a tikZ node like you do it in normal LaTeX. 

\tikzset{
every node/.style={text centered,draw,minimum height=1.5cm, minimum width=2cm,node distance=30pt}
}
\begin{tikzpicture}
    \node  [coordinate]  at (0,0.5)  (C){\normalsize C};
    \node  [coordinate,below = of C]   (M1){\small M1};
    \node  [right=of C, yshift=-0.5cm] (CP1){\Large MA};
    \node  [right=of CP1] (CP2)   {\small SC};
    \node  [right=of CP2] (CP3)   {\tiny DC};
    \node  [right=of CP3] (CP4)   {Switch};
    \node  [right=of CP4] (Output){\Huge Output};
    \draw [->, >=latex] (CP1) -- (CP2);
    \draw [->, >=latex] (CP2) -- (CP3);
    \draw [->, >=latex] (CP3) -- (CP4);
    \draw [->, >=latex] (CP4) -- (Output);
    \draw [->, >=latex](C)node[draw=none,,above=-0.5cm]{C} -- (C-|CP1.west);
    \draw [->, >=latex](M1)node[draw=none,below=-0.5cm]{M1} --(M1-|CP1.west);
\end{tikzpicture} 

\end{document}
share|improve this answer

Normally if you don't specify the size, the fonts come out in normal size (i.e., the font size of the document). tikz provides a key font for changing the font attributes. For example if you put

\begin{tikzpicture}[font=\tiny]

The font size inside the tikzpicture will be tiny uniformly unless you over ride later. This key has the advantage of keeping the content clean as we add it to the options of node.

Applying this font key to Jesse's code:

\documentclass[11pt]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz,xcolor}
\usetikzlibrary{positioning,calc,arrows}

\begin{document}

You can change the font size inside a tikZ node like you do it in normal LaTeX.

\tikzset{
every node/.style={text centered,draw,minimum height=1.5cm, minimum width=2cm,node distance=30pt}
}
\begin{tikzpicture}[font=\normalsize]    %% not needed generally
    \node  [coordinate]  at (0,0.5)  (C){C};
    \node  [coordinate,below = of C,font=\small]   (M1){M1};            %% <-- note the options
    \node  [right=of C, yshift=-0.5cm,font=\Large,text=red] (CP1){MA};
    \node  [right=of CP1,font=\small] (CP2)   {SC};
    \node  [right=of CP2,font=\tiny] (CP3)   {DC};
    \node  [right=of CP3] (CP4)   {Switch};
    \node  [right=of CP4,font=\Huge] (Output){Output};
    \draw [->, >=latex] (CP1) -- (CP2);
    \draw [->, >=latex] (CP2) -- (CP3);
    \draw [->, >=latex] (CP3) -- (CP4);
    \draw [->, >=latex] (CP4) -- (Output);
    \draw [->, >=latex](C)node[draw=none,,above=-0.5cm]{C} -- (C-|CP1.west);
    \draw [->, >=latex](M1)node[draw=none,below=-0.5cm]{M1} --(M1-|CP1.west);
\end{tikzpicture}

\end{document}

enter image description here

Similarly there is text key which is note worthy. For details refer pgfmanual.

share|improve this answer
    
... "refer to"! –  Lightness Races in Orbit Feb 2 at 2:29
    
@LightnessRacesinOrbit refer sounds al right to me ;) –  Harish Kumar Feb 2 at 2:33
    
Regardless, it's not. :) –  Lightness Races in Orbit Feb 2 at 2:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.