我正在使用PGF/Tikz图形,我想知道在小型/子图环境中使用图形时,如何控制图形中字体大小的缩放?

是否可以手动为PGF/TIKZ图形或一般乳胶设置永久字体大小,以使字体尺寸不变缩放?

理想情况下,我希望能够手动指定每个图形或所有图形或子图/小型环境的字体大小?

这是建议使用的示例。谢谢您的帮助。

\begin{figure}[h]
\centering
\subfloat[Graph 1]{
    \begin{minipage}[h]{0.7\linewidth}
        \centering\beginpgfgraphicnamed{graph1}
        \input{graph1.tex}
        \endpgfgraphicnamed
        \label{fig:graph1}
    \end{minipage}}
\hspace{5pt}
\subfloat[Graph 2]{
    \begin{minipage}[h]{0.5\linewidth}
        \centering\beginpgfgraphicnamed{graph2}
        \input{graph2.tex}
        \endpgfgraphicnamed
        \label{fig:graph2}
    \end{minipage}}
\subfloat[Graph 3]{
    \begin{minipage}[h]{0.5\linewidth}
        \centering\beginpgfgraphicnamed{graph3}
        \input{graph3.tex}
        \endpgfgraphicnamed
        \label{fig:graph3}
    \end{minipage}}
\caption{Three Graphs}
\end{figure}

也许在Minipage/subfig之外,我可以使用其他帖子中的建议使字体大,因为该图形用页面宽度缩放?在示例中,我要想要的是第一张图像,它自己是更大的,然后是两个小图,并在一个图中并排带有自己的标题。

我在您的个人资料云母中看到了一些R标签。图形是使用Tikzdevice生成的,并在我的乳胶文档中拾取。

因此,我在没有tikzpicture环境的情况下生成文件,以便我自己手动设置选项。当我使用 \begin{tikzpicture} \end{tikzpicture} 我有错误 “尺寸太大,我无法处理大于19英尺的尺寸。继续。继续,我会使用最大的价值。”. 。我需要使用 \beginpgfgraphicnamed{} .. \endpgfgraphicnamed{} 为了工作吗?不确定到底是什么影响。

这是自动生成文件的示例:

\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (794.97,614.29);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (794.97,614.29);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\end{scope}

........

\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (794.97,614.29);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\definecolor[named]{fillColor}{rgb}{1.00,1.00,1.00}

\draw[fill=fillColor,draw opacity=0.00,] (  0.00,  0.00) rectangle (794.97,614.29);
\end{scope}

........

\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (794.97,614.29);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\definecolor[named]{drawColor}{rgb}{0.00,0.00,0.00}

\node[rotate= 90.00,color=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale=  1.00] at ( 15.92,310.59) {Mackenzie Net Sales};
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (794.97,614.29);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\end{scope}

希望这很有帮助,整个文件都约为1,000行,因此我试图削减独特位的表示。请让我知道您是否需要其他任何东西。

非常感谢,

周杰伦

有帮助吗?

解决方案

我不确定您的目标是什么。要更改图片其余部分的字体大小或大小?有多种可能达到其中的可能性:

我的示例框,带有1厘米x 1厘米的大盒子:

\begin{tikzpicture}
    \draw (0,0) rectangle (1,1) -- +(-1,-1);
    \node(text) at (0.5,0.5) {Text};
\end{tikzpicture}

扩展图形元素,但不能扩展文本:

\begin{tikzpicture}[scale=0.5]
    \draw (0,0) rectangle (1,1) -- +(-1,-1);
    \node(text) at (0.5,0.5) {Text};
\end{tikzpicture}

\begin{tikzpicture}[scale=0.5]
    \draw (0,0) rectangle (1cm,1cm) -- +(-1,-1);
    \node(text) at (0.5cm,0.5cm) {Text};
\end{tikzpicture}

仅缩放坐标(即,如果没有指定单位,则使用指定的X,Y和Z向量的乘以):

\begin{tikzpicture}[x=5mm,y=5mm]
    \draw (0,0) rectangle (1,1) -- +(-1,-1);
    \node(text) at (0.5,0.5) {Text};
\end{tikzpicture}

明确的长度没有改变:

\begin{tikzpicture}[x=5mm,y=5mm]
    \draw (0,0) rectangle (1cm,1cm) -- +(-1cm,-1cm);
    \node(text) at (0.5cm,0.5cm) {Text};
\end{tikzpicture}

扩展所有内容,甚至是文本(根据PGFManual,不建议这样做):

\begin{tikzpicture}[transform canvas={scale=0.5}]
    \draw (0,0) rectangle (1,1) -- +(-1,-1);
    \node(text) at (0.5,0.5) {Text};
\end{tikzpicture}

使用乳胶命令相同的效果:

\scalebox{0.5}{
\begin{tikzpicture}
    \draw (0,0) rectangle (1,1) -- +(-1,-1);
    \node(text) at (0.5,0.5) {Text};
\end{tikzpicture}
}

在本地更改字体大小,但图形元素的大小不会更改:

\begin{tikzpicture}[font=\scriptsize]
    \draw (0,0) rectangle (1,1) -- +(-1,-1);
    \node(text) at (0.5,0.5) {Text};
\end{tikzpicture}

在所有后续的tikzpicture环境中更改字体大小(\tikzset 也可以用来设置上述选项):

\tikzset{font=\scriptsize}
\begin{tikzpicture}
    \draw (0,0) rectangle (1,1) -- +(-1,-1);
    \node(text) at (0.5,0.5) {Text};
\end{tikzpicture}

\tikzset 保持本地的本地:

\begin{minipage}{\linewidth}
\tikzset{font=\scriptsize}
\begin{tikzpicture}
    \draw (0,0) rectangle (1,1) -- +(-1,-1);
    \node(text) at (0.5,0.5) {Text};
\end{tikzpicture}
\end{minipage}

{
\tikzset{font=\scriptsize}
\begin{tikzpicture}
    \draw (0,0) rectangle (1,1) -- +(-1,-1);
    \node(text) at (0.5,0.5) {Text};
\end{tikzpicture}
}

\begin{tikzpicture}
    \draw (0,0) rectangle (1,1) -- +(-1,-1);
    \node(text) at (0.5,0.5) {Text};
\end{tikzpicture}

我不知道您是否可以编辑文件 graph?.tex, ,还是生成的?也许您可以将选项传递给生成的程序 tikzpicture 环境。否则,只需在您所需的范围中设置所需的选项 \tikzset.

希望,这会有所帮助。

编辑: :如果选项(喜欢 font=)在本地定义 graph?.tex, ,然后这些优先于外部定义的选项。如果是这种情况,您只是无法从外部覆盖它们。您必须编辑文件。

编辑: :这个“最小”示例对我有用(显示一个超过子图的宽度的非常大的“ Mackenzie Net销售”)

\documentclass{article}

\usepackage{fix-cm}
\usepackage{subfig}
\usepackage{tikz}

\begin{document}
\tikzset{every picture/.append style={font=\fontsize{100}{120}\selectfont}}

\begin{figure}[h]
\centering
\subfloat[Graph 1]{
    \begin{minipage}[h]{0.7\linewidth}
        \centering\beginpgfgraphicnamed{graph1}
%        \input{graph1.tex}
        \endpgfgraphicnamed
        \label{fig:graph1}
    \end{minipage}}
\hspace{5pt}
\subfloat[Graph 2]{
    \begin{minipage}[h]{0.5\linewidth}
        \centering 
        \resizebox{\textwidth}{!}{

            %\beginpgfgraphicnamed{graph2}  
\begin{tikzpicture}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (79.497,61.429);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (79.497,61.429);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (79.497,61.429);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\definecolor[named]{fillColor}{rgb}{1.00,1.00,1.00}
\draw[fill=fillColor,draw opacity=0.00,] (  0.00,  0.00) rectangle (79.497,61.429);
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (79.497,61.429);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\definecolor[named]{drawColor}{rgb}{0.00,0.00,0.00}
\node[rotate= 90.00,color=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale=  1.00] at ( 1.592,31.059) {Mackenzie Net Sales};
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (79.497,61.429);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\end{scope}
\end{tikzpicture}
}
        %\endpgfgraphicnamed

        \label{fig:graph2}
    \end{minipage}}
\subfloat[Graph 3]{
    \begin{minipage}[h]{0.5\linewidth}
        \centering\beginpgfgraphicnamed{graph3}
%        \input{graph3.tex}
        \endpgfgraphicnamed
        \label{fig:graph3}
    \end{minipage}}
\caption{Three Graphs}
\end{figure}

\end{document}

请测试这是否也适合您。如果确实如此,请尝试修改它,直到它不再起作用为止。破裂的变化是什么?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top