Tikz-Caption 位于我的身材上方

Tikz-Caption 位于我的身材上方

我的图有问题,标题与图重叠。如何解决?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fullpage} % Package to use full page
\usepackage{tikz} % Package for drawing
 \usepackage{amsmath}
 \renewcommand{\tablename}{Tab.}  
 \usetikzlibrary{shapes,arrows,calc,positioning,patterns,intersections}
% defining the new dimensions and parameters
\newlength{\hatchspread}
\newlength{\hatchthickness}
\newlength{\hatchshift}
\newcommand{\hatchcolor}{}
% declaring the keys in tikz
\tikzset{hatchspread/.code={\setlength{\hatchspread}{#1}},
     hatchthickness/.code={\setlength{\hatchthickness}{#1}},
     hatchshift/.code={\setlength{\hatchshift}{#1}},% must be >= 0
     hatchcolor/.code={\renewcommand{\hatchcolor}{#1}}}
 % setting the default values
 \tikzset{hatchspread=3pt,
     hatchthickness=0.4pt,
     hatchshift=0pt,% must be >= 0
     hatchcolor=black}
% declaring the pattern  
  \pgfdeclarepatternformonly[\hatchspread,\hatchthickness,\hatchshift,\hatchcolor]
    % variables
   {custom north west lines}% name
   {\pgfqpoint{\dimexpr-2\hatchthickness}{\dimexpr-2\hatchthickness}}% lower left corner
   {\pgfqpoint{\dimexpr\hatchspread+2\hatchthickness}{\dimexpr\hatchspread+2\hatchthickness}}% upper right corner
   {\pgfqpoint{\dimexpr\hatchspread}{\dimexpr\hatchspread}}% tile size
   {% shape description
    \pgfsetlinewidth{\hatchthickness}
    \pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\hatchspread+\hatchshift}}
    \pgfpathlineto{\pgfqpoint{\dimexpr\hatchspread+0.15pt+\hatchshift}{-0.15pt}}
    \ifdim \hatchshift > 0pt
      \pgfpathmoveto{\pgfqpoint{0pt}{\hatchshift}}
      \pgfpathlineto{\pgfqpoint{\dimexpr0.15pt+\hatchshift}{-0.15pt}}
    \fi
    \pgfsetstrokecolor{\hatchcolor}
%    \pgfsetdash{{1pt}{1pt}}{0pt}% dashing cannot work correctly in all situation this way
    \pgfusepath{stroke}
    }

\begin{document}
\begin{figure}[!h] 
\centering
\begin{minipage}[b][5cm][s]{.45\textwidth}
\centering
\begin{tikzpicture}[scale=0.6][grid/.style={pattern=MyGrid}]
%[x={10.0pt},y={10.0pt}]
  \draw[->] (0,0) -- (10,0) node[below] {$\tau$};
  \draw[->] (0,0) -- (0,10) node[left] {$C_M$};
  \draw[scale=1,domain=0:9.25,smooth,variable=\x,gray] plot ({\x},{\x});
  \draw[scale=1,domain=0.5:9.25,smooth,variable=\x,gray] plot ({\x},{5*\x^-1});
  \draw[scale=1,domain=0.55:9,smooth,variable=\x,blue,line width=0.25mm] 
  plot ({\x},{5*\x^-1+\x});
  \draw[-,dashed] (2.26,0) node[below]{$\tau_{opt}^{NV}$}--(2.26,4.5);
  \draw[-,dashed] (0,4.5) node[left]{$C_{M,min}$}--(2.26,4.5);
  \node[red] at (2.26,4.5){\textbullet};
  \draw[-,magenta] (0.9,0) node [below] {$\tau_{min}$} --(0.9,10);
  \fill[pattern=custom north west lines,hatchspread=10pt,hatchcolor=magenta] (0,0)   rectangle (0.9, 10);
  \node at (5,10.5) {\bfseries{Caso:} $\boldsymbol{\tau_{opt}^{NV}>\tau_{min}}$};
\end{tikzpicture} % pic 1
\end{minipage}\hspace{1cm}
\begin{minipage}[b][5cm][s]{.45\textwidth}
\centering
\begin{tikzpicture}[scale=0.6] %[x={10.0pt},y={10.0pt}]
  \draw[->] (0,0) -- (10,0) node[below] {$\tau$};
  \draw[->] (0,0) -- (0,10) node[left] {$C_M$};
  \draw[scale=1,domain=0:9.25,smooth,variable=\x,gray] plot ({\x},{\x});
  \draw[scale=1,domain=0.5:9.25,smooth,variable=\x,gray] plot ({\x},{5*\x^-1});
  \draw[scale=1,domain=0.55:9,smooth,variable=\x,blue,line width=0.25mm] plot ({\x},{5*\x^-1+\x});
  \draw[-,dashed] (2.26,0) node[below]{$\tau_{opt}^{NV}$}--(2.26,4.5);
  \draw[-,dashed] (0,4.5) node[left]{$C_{M,min}$}--(2.26,4.5);
  \node[red] at (2.26,4.5){\textbullet};
  \draw[-,magenta] (4,0) node [below] {$\tau_{min}$} --(4,10);
  \fill[pattern=custom north west lines,hatchspread=10pt,hatchcolor=magenta] (0,0)   rectangle (4, 10);
  \node at (5,10.5) {\bfseries{Caso:} $\boldsymbol{\tau_{opt}^{NV}<\tau_{min}}$};
\end{tikzpicture} % pic 2
\end{minipage}   
\caption{Casistiche per la definizione del rapporto di trasmissione ottimo vincolato}
\label{fig:tau_opt_vincolato} 
\end{figure}
\end{document}   

答案1

您的标题超出了图片,因为图片高于您指定的小页面高度 5 厘米。您可以

  • 增加这个高度,
  • 根本不使用固定高度,或者
  • (我最喜欢的)根本不使用小页面。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fullpage} % Package to use full page
\usepackage{tikz} % Package for drawing
 \usepackage{amsmath}
 \renewcommand{\tablename}{Tab.}  
 \usetikzlibrary{shapes,arrows,calc,positioning,patterns,intersections}
% defining the new dimensions and parameters
\newlength{\hatchspread}
\newlength{\hatchthickness}
\newlength{\hatchshift}
\newcommand{\hatchcolor}{}
% declaring the keys in tikz
\tikzset{hatchspread/.code={\setlength{\hatchspread}{#1}},
     hatchthickness/.code={\setlength{\hatchthickness}{#1}},
     hatchshift/.code={\setlength{\hatchshift}{#1}},% must be >= 0
     hatchcolor/.code={\renewcommand{\hatchcolor}{#1}}}
 % setting the default values
 \tikzset{hatchspread=3pt,
     hatchthickness=0.4pt,
     hatchshift=0pt,% must be >= 0
     hatchcolor=black}
% declaring the pattern  
  \pgfdeclarepatternformonly[\hatchspread,\hatchthickness,\hatchshift,\hatchcolor]
    % variables
   {custom north west lines}% name
   {\pgfqpoint{\dimexpr-2\hatchthickness}{\dimexpr-2\hatchthickness}}% lower left corner
   {\pgfqpoint{\dimexpr\hatchspread+2\hatchthickness}{\dimexpr\hatchspread+2\hatchthickness}}% upper right corner
   {\pgfqpoint{\dimexpr\hatchspread}{\dimexpr\hatchspread}}% tile size
   {% shape description
    \pgfsetlinewidth{\hatchthickness}
    \pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\hatchspread+\hatchshift}}
    \pgfpathlineto{\pgfqpoint{\dimexpr\hatchspread+0.15pt+\hatchshift}{-0.15pt}}
    \ifdim \hatchshift > 0pt
      \pgfpathmoveto{\pgfqpoint{0pt}{\hatchshift}}
      \pgfpathlineto{\pgfqpoint{\dimexpr0.15pt+\hatchshift}{-0.15pt}}
    \fi
    \pgfsetstrokecolor{\hatchcolor}
%    \pgfsetdash{{1pt}{1pt}}{0pt}% dashing cannot work correctly in all situation this way
    \pgfusepath{stroke}
    }

\begin{document}
\begin{figure}[!h] 
\centering
%\begin{minipage}[b][7cm][s]{.45\textwidth}
%\centering
\begin{tikzpicture}[scale=0.6][grid/.style={pattern=MyGrid}]
%[x={10.0pt},y={10.0pt}]
  \draw[->] (0,0) -- (10,0) node[below] {$\tau$};
  \draw[->] (0,0) -- (0,10) node[left] {$C_M$};
  \draw[scale=1,domain=0:9.25,smooth,variable=\x,gray] plot ({\x},{\x});
  \draw[scale=1,domain=0.5:9.25,smooth,variable=\x,gray] plot ({\x},{5*\x^-1});
  \draw[scale=1,domain=0.55:9,smooth,variable=\x,blue,line width=0.25mm] 
  plot ({\x},{5*\x^-1+\x});
  \draw[-,dashed] (2.26,0) node[below]{$\tau_{opt}^{NV}$}--(2.26,4.5);
  \draw[-,dashed] (0,4.5) node[left]{$C_{M,min}$}--(2.26,4.5);
  \node[red] at (2.26,4.5){\textbullet};
  \draw[-,magenta] (0.9,0) node [below] {$\tau_{min}$} --(0.9,10);
  \fill[pattern=custom north west lines,hatchspread=10pt,hatchcolor=magenta] (0,0)   rectangle (0.9, 10);
  \node at (5,10.5) {\bfseries{Caso:} $\boldsymbol{\tau_{opt}^{NV}>\tau_{min}}$};
\end{tikzpicture} % pic 1
%\end{minipage}
\hfill
%\begin{minipage}[b][7cm][s]{.45\textwidth}
%\centering
\begin{tikzpicture}[scale=0.6] %[x={10.0pt},y={10.0pt}]
  \draw[->] (0,0) -- (10,0) node[below] {$\tau$};
  \draw[->] (0,0) -- (0,10) node[left] {$C_M$};
  \draw[scale=1,domain=0:9.25,smooth,variable=\x,gray] plot ({\x},{\x});
  \draw[scale=1,domain=0.5:9.25,smooth,variable=\x,gray] plot ({\x},{5*\x^-1});
  \draw[scale=1,domain=0.55:9,smooth,variable=\x,blue,line width=0.25mm] plot ({\x},{5*\x^-1+\x});
  \draw[-,dashed] (2.26,0) node[below]{$\tau_{opt}^{NV}$}--(2.26,4.5);
  \draw[-,dashed] (0,4.5) node[left]{$C_{M,min}$}--(2.26,4.5);
  \node[red] at (2.26,4.5){\textbullet};
  \draw[-,magenta] (4,0) node [below] {$\tau_{min}$} --(4,10);
  \fill[pattern=custom north west lines,hatchspread=10pt,hatchcolor=magenta] (0,0)   rectangle (4, 10);
  \node at (5,10.5) {\bfseries{Caso:} $\boldsymbol{\tau_{opt}^{NV}<\tau_{min}}$};
\end{tikzpicture} % pic 2
%\end{minipage}   
\caption{Casistiche per la definizione del rapporto di trasmissione ottimo vincolato}
\label{fig:tau_opt_vincolato} 
\end{figure}
\end{document}   

在此处输入图片描述

相关内容