首頁>LaTeX>source

我有一整頁,我已設法用 \resizebox縮小 .不幸的是,在我在MwE中發現這个之後,我把它放迴到我的文件中,標题現在在頁脚中...

How do I account for the caption in my resize box or include the caption within the resize box?

MwE:

\documentclass{article}
\usepackage[letterpaper, margin=0.5in, includefoot]{geometry} % Advanced page geometry configuation
\usepackage{fancyhdr} % Used for header and footer creation
\pagestyle{fancy}
\fancyhf{} % clear all fields
\lfoot{Lorem\\Ipsum}\cfoot{dolor sit\\amet \\ \thepage}\rfoot{Rev. \#\\ \today}
\usepackage{tikz} % Flowcharts
\renewcommand{\headrulewidth}{0.0pt} % removes line at top that comes w/ fancyhdr
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows, positioning, calc, matrix}
% Define block styles
\tikzstyle{state}   = [ rounded rectangle, 
                        draw, 
                        text centered, 
                        minimum height = 3em,
                        minimum width = 6em,
                        inner sep = 5pt
                        ]
\tikzstyle{test}    = [ diamond, 
                        draw, 
                        shape aspect = 2, 
                        inner sep = 0pt,
                        text width = 7em,
                        text centered 
                      ]
\tikzstyle{action}  = [ rectangle, draw,
                        text width = 8em,
                        inner sep = 5pt, 
                        minimum height = 5em
                      ]
\tikzstyle{data}    = [ trapezium, 
                        draw, 
                        trapezium left angle = 60, 
                        trapezium right angle = 120pt,
                        minimum height = 6em, 
                        text width = 5em,
                        inner xsep = 0pt
                       ]
\tikzstyle{line}    = [ draw, -triangle 45 ]
\begin{document}

\begin{figure}[H]
\begin{center}
\resizebox{\textwidth}{\textheight}{%
\input{./flowchart.tex}
}
\caption{\textbf {My Stupid Flowchart} }
\end{center}
\end{figure} 

\end{document}

Flowchart.tex:

\resizebox{\textwidth}{\textheight}{%
\begin{tikzpicture}[align = flush center, font = \small]

    % Place nodes
    \matrix [matrix of nodes, column sep = 0.5em, row sep = 1.3em,
                draw, dotted,
                nodes={solid},
                matrix anchor=south east,
                inner sep = 1em,
                ampersand replacement=\&
                ] (state-mtrx)  at (0,0) 
    {            
    |[data] (a)| Lorem ipsum dolor sit amet, c \\        
    |[test] (b)| Lorem ipsum d \\
    |[action] (c)| Lorem ipsum dolor sit amet, consectetur adipiscing\\        
    |[test] (d)| Lorem ipsum dolor  \\         
    |[action] (e)| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque tempus nisl id  \\   
    |[test] (f)| Lorem ipsum dolor sit amet, \\    
    |[action] (g)| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque tempus nisl id lectus\\  
    |[action] (h)| Lorem ipsum dolor sit amet, consectetur adipiscing eli \\[1em]
    |[action] (j)| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque tempus nisl id \\
    [1em]\\
     }; 
    \matrix [matrix of nodes, column sep = 0.5em, row sep = 1.3em,
                nodes = {solid},
                draw, dotted,
                matrix anchor=south west,
                inner xsep = 3em,
                ampersand replacement=\&
                ] (state-send-response) at (0,0) 
    {
    \\
    \\
    \\ 
    \&|[test] (i)| Lorem ipsum dolor? \\    
    \&|[test] (k)| ILorem ipsum dolor sit amet,? \\    
    \&|[action] (l)| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque \\ [1em]   
    \&|[data] (m)| Lorem ipsum dolor sit amet, consect \\    
    |[state] (n)| Lorem ipsum dolor sit 
    \&|[state] (p)| Lorem ipsum dolor\\   
    }; 
    \node[state, above = of a] (write) {WLorem ipsu};  
    \path [] ([shift={(-3mm, 0)}]state-mtrx.north west) -- ([shift={(-3mm, 0)}]state-mtrx.south west) coordinate(state-line);
    \path let \p1=(state-line), \p2=($ (a)!0.5!(b)$ ) in (\p2) -- node [left, very near end] {Lorem ipsum dolor} (\x1,\y2);
    \path let \p1=(state-line), \p2=($ (c)!0.5!(d)$ ) in (\p2) -- node [left, very near end] {Lorem ipsum dolor sit am} (\x1,\y2);
    \path let \p1=(state-line), \p2=($ (e)!0.5!(f)$ ) in (\p2) -- node [left, very near end] {Lorem ipsum dol} (\x1,\y2);
    \path let \p1=(state-line), \p2=(g) in (\p2) -- node [left, very near end] {Lorem ipsum dolor} (\x1,\y2);
    \path let \p1=(state-line), \p2=(h) in (\p2) -- node [left, very near end] {Lorem ipsum dolo\\Lorem ipsum dol} (\x1,\y2);
    \path let \p1=(state-line), \p2=(j) in (\p2) -- node [left, very near end] {Lorem ipsum dolo} (\x1,\y2);
    \node [above = 0em of state-send-response.north] {Lorem ipsum dolor s};
% Draw edges
    % Dotted separators
    \path [draw, dotted] let \p1=( $(b.south)!0.5!(c.north)$ ), \p2=(state-mtrx.north west), \p3=(state-mtrx.north east) in (\x2, \y1) -- (\x3, \y1);
    \path [draw, dotted] let \p1=( $(d.south)!0.5!(e.north)$ ), \p2=(state-mtrx.north west), \p3=(state-mtrx.north east) in (\x2, \y1) -- (\x3, \y1);
    \path [draw, dotted] let \p1=( $(f.south)!0.5!(g.north)$ ), \p2=(state-mtrx.north west), \p3=(state-mtrx.north east) in (\x2, \y1) -- (\x3, \y1);
    \path [draw, dotted] let \p1=( $(g.south)!0.5!(h.north)$ ), \p2=(state-mtrx.north west), \p3=(state-mtrx.north east) in (\x2, \y1) -- (\x3, \y1);
    \path [draw, dotted] let \p1=( $(h.south)!0.3!(j.north)$ ), \p2=(state-mtrx.north west), \p3=(state-mtrx.north east) in (\x2, \y1) -- (\x3, \y1);

     % left State Paths      
    \path [line] (write) -- (a);
    \path [line] (a) -- (b);
    %% (d) paths - not in order because of reference point (d-no)
    \path [line] (d) -- node [right, near start] {Yes} (e);
    \path [line] (d.east) -- node [above, near start] {No} +(1.5,0)coordinate(d-no) -| (i);
    \path [line] (b) -- node [right, very near start] {Yes} (c);
    \path [line] (b) -| node [above, pos=0.02] {No} (d-no);
    \path [line] (c) -- (d);
    \path [line] (e) -- (f);
    \path [line] let \p1=([shift={(2mm, 0)}]state-mtrx.west), \p2=(f.west) in (\p2) -- node [above, near start] {Yes} (\x1, \y2) |- ( $(h.south)!0.5!(j.north)$ );
    \path [line] (f) -- node [right, near start] {No} (g);
    \path [] (b.east) -- +(1,0)coordinate(copy-no);
    \path [line] (j.south) |- ([shift={(2mm, 2em)}]state-mtrx.south east) -| (d-no);
    \path [line] (g) -- (h);
    \path [line] (h) -- (j);
    % Response State paths
    \path [line] (i.east) -- node [above, near start] {Yes} +(1,0) |- ( $(l.south)!0.3!(m.north)$ );
    \path [line] (i.south) -- node [right] {No} (k);
    \path [line] (k) -- node [right] {Yes} (l);
    \path [line] (k.west) -| node [above, very near start] {No} (n);
    \path [line] (l) -- (m);
    \path [line] (m) -- (p);   
\end{tikzpicture}
}
最新回復
  • 2019-12-5
    1 #

    以下方法將標题放在框中並測量其高度.然後是 \resizebox高度的值   可以計算。

      In flowchart   我删除了額外的 \resizebox .另外我在 \end{tikzpicture}之後評論了線端 .我们處於水平模式,這意味着空間有助於宽度.我也删除了post \input{./flowchart.tex}的空間   出於同樣的原因。

      我添加了選項 showframe   對於包 geometry   顯示文字正文的邊框。

      \resizebox   不太準確.因此,我將圖中的內容包裹在另外一个 \vbox中   內部有一个小的修正。

      \hspace{-0.3333em}   取消 inner sep   最左邊的文字节點。
      Update:   我把它移到了檔案 flowchart.tex ,因為它是流程圖的屬性.只需在wy​​zwyz之前添加以下行 :

      \begin{tikzpicture}
      

      \hspace*{-.3333em}% remove left `inner sep` from the leftmost text node   防止圖片框和標题框之間有額外的膠水。

      \nointerlineskip   如果流程圖溢位可用的宽度或高度,則仅縮放流程圖。

      示例檔案:

      Update:
      
      測量位置

      第二種方法使用包 \documentclass{article} \usepackage[showframe,letterpaper, margin=0.5in, includefoot]{geometry} % Advanced page geometry configuation \usepackage{fancyhdr} % Used for header and footer creation \pagestyle{fancy} \fancyhf{} % clear all fields \lfoot{Lorem\\Ipsum}\cfoot{dolor sit\\amet \\ \thepage}\rfoot{Rev. \#\\ \today} \usepackage{tikz} % Flowcharts \renewcommand{\headrulewidth}{0.0pt} % removes line at top that comes w/ fancyhdr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary{shapes, arrows, positioning, calc, matrix} % Define block styles \tikzstyle{state} = [ rounded rectangle, draw, text centered, minimum height = 3em, minimum width = 6em, inner sep = 5pt ] \tikzstyle{test} = [ diamond, draw, shape aspect = 2, inner sep = 0pt, text width = 7em, text centered ] \tikzstyle{action} = [ rectangle, draw, text width = 8em, inner sep = 5pt, minimum height = 5em ] \tikzstyle{data} = [ trapezium, draw, trapezium left angle = 60, trapezium right angle = 120pt, minimum height = 6em, text width = 5em, inner xsep = 0pt ] \tikzstyle{line} = [ draw, -triangle 45 ] \newsavebox\captionbox \newsavebox\flowchartbox \newdimen\flowchartmaxheight \newcommand*{\maxminipageheight}{% \dimexpr\ifdim\height>\textheight\textheight\else\height\fi\relax } \begin{document} \begin{figure} \begin{minipage}[b][\maxminipageheight][c]{\textwidth}% \sbox\captionbox{% \parbox[b]{\textwidth}{% \centering \caption{\textbf {My Stupid Flowchart}}% }% }% \sbox\flowchartbox{\input{flowchart}}% \pgfmathsetlength{\flowchartmaxheight}{\textheight-\ht\captionbox}% \ifdim\ht\flowchartbox>\flowchartmaxheight \sbox\flowchartbox{% \resizebox{!}{\flowchartmaxheight}{\box\flowchartbox}% }% \fi \ifdim\wd\flowchartbox>\textwidth \sbox\flowchartbox{% \resizebox{\textwidth}{!}{\box\flowchartbox}% }% \fi \centerline{\box\flowchartbox}% \vspace{0pt minus .5pt}% fix for rounding errors in \resizebox \nointerlineskip \centerline{\box\captionbox}% \end{minipage}% \end{figure} \end{document}   測量寫入 zref-abspage的位置   先归档.在第二次執行中,正確的位置是已知和使用的 .aux   此示例更新了有關縮放行為的資訊。

      Update:
      
      \documentclass{article} \usepackage[showframe,letterpaper, margin=0.5in, includefoot]{geometry} % Advanced page geometry configuation \usepackage{fancyhdr} % Used for header and footer creation \pagestyle{fancy} \fancyhf{} % clear all fields \lfoot{Lorem\\Ipsum}\cfoot{dolor sit\\amet \\ \thepage}\rfoot{Rev. \#\\ \today} \usepackage{tikz} % Flowcharts \renewcommand{\headrulewidth}{0.0pt} % removes line at top that comes w/ fancyhdr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary{shapes, arrows, positioning, calc, matrix} % Define block styles \tikzstyle{state} = [ rounded rectangle, draw, text centered, minimum height = 3em, minimum width = 6em, inner sep = 5pt ] \tikzstyle{test} = [ diamond, draw, shape aspect = 2, inner sep = 0pt, text width = 7em, text centered ] \tikzstyle{action} = [ rectangle, draw, text width = 8em, inner sep = 5pt, minimum height = 5em ] \tikzstyle{data} = [ trapezium, draw, trapezium left angle = 60, trapezium right angle = 120pt, minimum height = 6em, text width = 5em, inner xsep = 0pt ] \tikzstyle{line} = [ draw, -triangle 45 ] \usepackage{zref-savepos} \providecommand*{\zsaveposy}{\zsavepos}% support older zref-savepos \newdimen\flowheight \begin{document} \begin{figure} \vbox to \textheight{% \centering \makeatletter \zsaveposy{flow-beg}% \[email protected]{flow-beg}% \setlength{\flowheight}{-\dimexpr\zposy{flow-end}sp-\zposy{flow-beg}sp\relax}% \resizebox{\textwidth}{% \ifdim\flowheight>0pt \flowheight\else .75\textheight\fi }{% \input{flowchart}% }\par \vss \nointerlineskip \zsaveposy{flow-end}% \caption{\textbf {My Stupid Flowchart}}% } \end{figure} \end{document}

      Result

  • 如何用tikz更改這些公式?
  • LaTeX xetex:使用xelatex以Monospace字型顯示不正確的符號