2

I am trying to write code for a diagram I have in tikz. I am very new to tikz so this may be an easy question but here goes. I have some code like the following:

\begin{tikzpicture}[scale=.95]
\draw [<->, thick] (0,0) coordinate (a_1) -- (2,1.8) coordinate (a_2)node[right]{$\mathcal{M}$};
\draw [<->, thick, color=black!40!blue] (1,0) coordinate (b_1) node[right]{$\mathcal{N}$}-- (1,2) coordinate (b_2);

\coordinate (c) at (intersection of a_1--a_2 and b_1--b_2);
\fill (c) circle (2pt) node[right]{$X$};
\end{tikzpicture}

But the issue I am having is that in more complicated diagrams, the text labels are in too large of font and intersects with lines. How can I make the font in the label nodes smaller?

5

You can use the font key as an optional argument to the tikzpicture.

\begin{tikzpicture}[font=\footnotesize]
% ....
\end{tikzpicture}

Or if you want this for all your tikzpictures in your document, put this somewhere in your preamble:

\tikzset{every picture/.append style={font=\footnotesize}}
  • 1
    \tikzstyle is obsolete. Please use \tikzset and the /.append style key instead. – Tobi Sep 5 '13 at 20:38
  • @Tobi, you are right, I know. I still prefer the old style... Nonetheless I changed it to the recommended way. – quinmars Sep 5 '13 at 21:03
  • 1
    See Should \tikzset or \tikzstyle be used to define TikZ styles? for some more information on this topic. – Tobi Sep 5 '13 at 21:46
0

As you notice the letters are inside nodes, so you can specify in each node in the attribute ``font'' the size desired, besides that, you can specify the relative positions of your text, below I am attaching your code with some node letter size attributes:


\begin{tikzpicture}[scale=.95]
\draw [<->, thick] (0,0) coordinate (a_1) -- (2,1.8) coordinate (a_2)node[right, font=\tiny, anchor=270]{$M_{270}$}node[right, font=\tiny, anchor=180]{$M_{180}$}node[right, font=\tiny, anchor=150]{$M_{150}$};
\draw [<->, thick, color=black!40!blue] (1,0) coordinate (b_1) node[right, font=\tiny, anchor=south west]{$\mathcal{N}$}-- (1,2) coordinate (b_2);

\coordinate (c) at (intersection of a_1--a_2 and b_1--b_2);
\fill (c) circle (2pt) node[right, font=\tiny, anchor=east]{$X$};
\end{tikzpicture}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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