在minipage/subfig中缩放时,控制LaTeX中图形的字体大小吗? [英] Control font size in graphics in LaTeX when scaling in minipage/subfig?

查看:314
本文介绍了在minipage/subfig中缩放时,控制LaTeX中图形的字体大小吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用pgf/tikz图形,并且想知道在minipage/subfig环境中使用它们时,如何控制图形中字体大小的缩放比例?

I am using pgf/tikz graphics and I'm wondering how one can control the scaling of font sizes in the graphics when using them in minipage/subfig environments?

有没有一种方法可以手动为pgf/tikz图形或一般在乳胶中设置永久的字体大小,以使字体大小不随缩放而变化?

Is there a way to manually set a permanent font size for pgf/tikz graphics or in latex in general so as to make font sizing invariant to scaling?

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

以下是建议用法的一个示例.感谢您的帮助.

Here is an example of the usage as suggested. Thanks for the help.

\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之外,我可以使用其他文章中的建议来使字体变大,因为图形是根据页面宽度缩放的?在该示例中,我想要的是第一张单独的图像,较大的图像,然后是两个小图像,它们并排在下面,并在一个图中带有其自己的标题.

Perhaps outside of minipage/subfig I can use the suggestions from the other posting to make the font large since the graphic is scaled with the page width? What I was going for in the example was the first image on it's own, larger, and then two smallimages right below side by side with their own captions in one figure.

我在您的个人资料Mica中看到了一些R标签.这些图形是使用tikzDevice生成的,并在我的乳胶文档中获取.

I saw some R tags in your profile Mica. The graphics are generated using tikzDevice and are picked up in my latex doc.

因此,我在没有tikzpicture环境的情况下生成文件,以便可以自己在其中手动设置选项.当我使用\begin{tikzpicture} \end{tikzpicture}时,出现错误尺寸太大,无法使用大于19英尺的尺寸.继续,我将使用最大的值." .我需要使用\beginpgfgraphicnamed{} .. \endpgfgraphicnamed{}使其正常工作吗?不确定影响到底是什么.

So I'm generating the files without the tikzpicture environment so that I can manually set options there myself. When I use the \begin{tikzpicture} \end{tikzpicture} I get the error "Dimension too large I can't work with sizes bigger than about 19 feet. Continue and I'll use the largest value I can.". I need to use \beginpgfgraphicnamed{} .. \endpgfgraphicnamed{} to get it to work? Not sure what the impact is exactly.

以下是自动生成的文件的示例:

\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行,因此我尝试剪切出唯一位的表示形式.如果您还有其他需要,请告诉我.

Hopefully that is helpful, over all the file is ~1,000 lines so I tried to cut out a representation of the unique bits. Please let me know if you need anything else.

非常感谢,

周杰伦

推荐答案

我不确定您的目标是什么.要更改字体大小还是图片其余部分的大小?有多种实现这些可能性的可能性:

I am not exactly sure what your aim is. To change the font size or the size of the Rest of the picture? There are multiple possibilities to reach any of these:

我的示例盒子有一个1cm x 1cm的大盒子:

My example box with a 1cm x 1cm large box:

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

缩放图形元素,但不缩放文本:

Scale the graphical elements, but NOT the text:

\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向量的乘积):

Scale the coordinates only (That is, if no unit is specified, it used multiplies of the specified x, y and z vector):

\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,不建议这样做):

Scale everything, even the text (according to the pgfmanual, this is not recommended):

\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}

使用LaTeX命令具有相同的效果:

Same effect using LaTeX commands:

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

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

Change the font size locally, but the size of graphical elements are not changed:

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

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

Change the font size in all subsequent tikzpicture environments (\tikzset can be used to set the options above, too):

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

\tikzset在组中仍然是本地的:

\tikzset remains local in groups:

\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在所需范围内设置所需选项.

I don't know whether you can edit the files graph?.tex, or are these generated? Maybe you can pass options to the program that generates the tikzpicture environment. Otherwise, just set the desired option in your desired scope using \tikzset.

希望,会有所帮助.

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

EDIT: If the options (like font=) are defined locally in the graph?.tex, then these get precedence over the options defined outside. If this is the case, you just can't overwrite them from the outside. You'd have to edit the files.

编辑:这个最小"示例对我有用(显示了一个很大的"Mackenzie净销售额",超过了子图的宽度)

EDIT: This "minimal" example works for me (showing a really big "Mackenzie Net Sales" that exceeds the subfigure's width)

\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}

请测试这是否也适合您.如果可以,请尝试修改此选项,直到不再起作用为止.重大变化是什么?

Please test whether this works for you, too. If it does, then try to modify this one until it doesn't work any more. What's the breaking change?

这篇关于在minipage/subfig中缩放时,控制LaTeX中图形的字体大小吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆