简体   繁体   中英

How to control font sizes in pgf/tikz graphics in latex?

I'm creating graphs in pgf/tikz. When I use these in my document they are scaled, several are in minipage/subfig like environments. When this happens the font sizes are scaled with the graphics making them very small or unreadable. I've been through the manual but have so far been unsuccessful in my attempts to control this.

Is there a way to set the font size directly? What options are there?

One aswer given below shows how to how to use the \\tikzstyle font option to specify the font size within the tikzpicture environment.

Right now I am using:

\beginppgfgraphicnamed{graph}
\input{graph.tex}
\endpgfgraphicnamed

The tikzpicture environment is used in the input file. Are there anyways to specify font size in the setup I'm using? Is this perhaps the issue? The graph.tex file is generated automatically via another program.

In addition to setting font size for individual graphics it would be ideal to have a parameter to globally set font size for all tikz graphics? I guess the issue is the scaling in minipage or subfig .

Many thanks,

Jay

\begin{tikzpicture}

    \tikzstyle{every node}=[font=\small]

\end{tikzpicture}

will give you font size control on every node.

I found the better control would be using scalefnt package:

\usepackage{scalefnt}
...
{\scalefont{0.5}
\begin{tikzpicture}
...
\end{tikzpicture}
}

我相信Mica的方式值得回答,因为作为评论不够明显:

\begin{tikzpicture}[font=\small]

You can also use:

\usepackage{anyfontsize}

The huge advantage of the anyfontsize package over scalefnt is that one does not need to enclose the entire {tikzpicture} with a \\scalefont environment.

Just adding \\usepackage{anyfontsize} to the preamble is all that is required for the font scaling magic to happen.

\begin{tikzpicture}
    \tikzstyle{every node}=[font=\fontsize{30}{30}\selectfont]
\end{tikzpicture}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM