[英]Control font size in graphics in LaTeX when scaling in minipage/subfig?
我正在使用pgf / tikz圖形,我想知道在minipage / subfig環境中使用它們時如何控制圖形中字體大小的縮放?
有沒有辦法手動設置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之外我可以使用其他帖子的建議來使字體變大,因為圖形是用頁面寬度縮放的? 在這個例子中我想要的是它自己的第一個圖像,更大,然后是兩個小圖像,並排在一個圖中,並排在一起。
我在你的個人資料Mica中看到了一些R標簽。 圖形是使用tikzDevice生成的,並在我的latex文檔中提取。
所以我在沒有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}
使用LaTeX命令的效果相同:
\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
本地定義graph?.tex
,那么這些選項優先於外部定義的選項。 如果是這種情況,您就無法從外部覆蓋它們。 你必須編輯文件。
編輯 :這個“最小”的例子適用於我(顯示超過子圖寬度的非常大的“Mackenzie Net Sales”)
\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 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.