如果我使用这个代码,
\documentclass{article}
\usepackage{tikz}
\usepackage{multicol,float}
\usepackage{etoolbox}% provides \preto
\usetikzlibrary{shapes,backgrounds}
\tikzset{
every node/.style={midway},
every path/.style={fill=yellow},
mid/.style={midway, inner sep=2pt, outer sep=0,minimum size=1mm, fill=yellow,node on layer=foreground},
}
\begin{document}
\begin{figure}[H]
\begin{tikzpicture}[scale = 4]
\draw (0.445041,0.801937) rectangle (0,1) node[mid] {$1$};
\draw (0.692021,0.356896) rectangle (1,1) node[mid] {$2$};
\draw (0.692021,0.356895) rectangle (0,0) node[mid] {$3$};
\draw (0.137063,0.158832) rectangle (0,1) node[mid] {$4$};
\draw (0.384043,0.713791) rectangle (1,0) node[mid] {$5$};
\draw (0.829084,0.515727) rectangle (0,1) node[mid] {$6$};
\draw (0.521105,0.872622) rectangle (0,0) node[mid] {$7$};
\end{tikzpicture}
\centering
\caption{M1}
\end{figure}
\end{document}
标题的结果是“图 1:M1”。是否可以将其更改为“M1”?
答案1
三个选项;前两个是加载caption
包,第三个是不加载包:
使用
\caption*
:\documentclass{article} \usepackage{tikz} \usetikzlibrary{backgrounds} \usepackage{multicol,float} \usepackage{etoolbox}% provides \preto \usepackage{caption} \usetikzlibrary{shapes,backgrounds} \tikzset{ every node/.style={midway}, every path/.style={fill=yellow}, mid/.style={midway, inner sep=2pt, outer sep=0,minimum size=1mm, fill=yellow}, } \begin{document} \begin{figure}[H] \centering \begin{tikzpicture}[scale = 4] \draw (0.445041,0.801937) rectangle (0,1) node[mid] {$1$}; \draw (0.692021,0.356896) rectangle (1,1) node[mid] {$2$}; \draw (0.692021,0.356895) rectangle (0,0) node[mid] {$3$}; \draw (0.137063,0.158832) rectangle (0,1) node[mid] {$4$}; \draw (0.384043,0.713791) rectangle (1,0) node[mid] {$5$}; \draw (0.829084,0.515727) rectangle (0,1) node[mid] {$6$}; \draw (0.521105,0.872622) rectangle (0,0) node[mid] {$7$}; \end{tikzpicture} \caption*{M1} \end{figure} \end{document}
声明
labelformat
为empty
使用本地\captionsetup
:\documentclass{article} \usepackage{tikz} \usetikzlibrary{backgrounds} \usepackage{multicol,float} \usepackage{etoolbox}% provides \preto \usepackage{caption} \usetikzlibrary{shapes,backgrounds} \tikzset{ every node/.style={midway}, every path/.style={fill=yellow}, mid/.style={midway, inner sep=2pt, outer sep=0,minimum size=1mm, fill=yellow}, } \begin{document} \begin{figure}[H] \captionsetup{labelformat=empty} \centering \begin{tikzpicture}[scale = 4] \draw (0.445041,0.801937) rectangle (0,1) node[mid] {$1$}; \draw (0.692021,0.356896) rectangle (1,1) node[mid] {$2$}; \draw (0.692021,0.356895) rectangle (0,0) node[mid] {$3$}; \draw (0.137063,0.158832) rectangle (0,1) node[mid] {$4$}; \draw (0.384043,0.713791) rectangle (1,0) node[mid] {$5$}; \draw (0.829084,0.515727) rectangle (0,1) node[mid] {$6$}; \draw (0.521105,0.872622) rectangle (0,0) node[mid] {$7$}; \end{tikzpicture} \caption{M1} \end{figure} \end{document}
根本不要使用
\caption
;只需放置文本:\documentclass{article} \usepackage{tikz} \usetikzlibrary{backgrounds} \usepackage{multicol,float} \usepackage{etoolbox}% provides \preto \usetikzlibrary{shapes,backgrounds} \tikzset{ every node/.style={midway}, every path/.style={fill=yellow}, mid/.style={midway, inner sep=2pt, outer sep=0,minimum size=1mm, fill=yellow}, } \begin{document} \begin{figure}[H] \centering \begin{tikzpicture}[scale = 4] \draw (0.445041,0.801937) rectangle (0,1) node[mid] {$1$}; \draw (0.692021,0.356896) rectangle (1,1) node[mid] {$2$}; \draw (0.692021,0.356895) rectangle (0,0) node[mid] {$3$}; \draw (0.137063,0.158832) rectangle (0,1) node[mid] {$4$}; \draw (0.384043,0.713791) rectangle (1,0) node[mid] {$5$}; \draw (0.829084,0.515727) rectangle (0,1) node[mid] {$6$}; \draw (0.521105,0.872622) rectangle (0,0) node[mid] {$7$}; \end{tikzpicture}\par\medskip M1 \end{figure} \end{document}
在最后一种情况下,如果您不想要浮动,您也可以简单地使用
minipage
居中内容:\documentclass{article} \usepackage{tikz} \usetikzlibrary{backgrounds} \usepackage{multicol,float} \usepackage{etoolbox}% provides \preto \usepackage{caption} \usetikzlibrary{shapes,backgrounds} \tikzset{ every node/.style={midway}, every path/.style={fill=yellow}, mid/.style={midway, inner sep=2pt, outer sep=0,minimum size=1mm, fill=yellow}, } \begin{document} \noindent\begin{minipage}{\linewidth} \centering \begin{tikzpicture}[scale = 4] \draw (0.445041,0.801937) rectangle (0,1) node[mid] {$1$}; \draw (0.692021,0.356896) rectangle (1,1) node[mid] {$2$}; \draw (0.692021,0.356895) rectangle (0,0) node[mid] {$3$}; \draw (0.137063,0.158832) rectangle (0,1) node[mid] {$4$}; \draw (0.384043,0.713791) rectangle (1,0) node[mid] {$5$}; \draw (0.829084,0.515727) rectangle (0,1) node[mid] {$6$}; \draw (0.521105,0.872622) rectangle (0,0) node[mid] {$7$}; \end{tikzpicture}\par\medskip M1 \end{minipage} \end{document}
答案2
有一个选项(5),它使用完全相同的代码,但是没有命令,而是这两行\caption
:
\begin{figure}[H]
\end{figure}
简单地,{M1}
\documentclass{article}
\usepackage{tikz}
\usepackage{multicol,float}
\usepackage{etoolbox}% provides \preto
\usetikzlibrary{shapes,backgrounds}
\tikzset{
every node/.style={midway},
every path/.style={fill=yellow},
mid/.style={midway, inner sep=2pt, outer sep=0,minimum size=1mm, fill=yellow,node on layer=foreground},
}
\begin{document}
\begin{tikzpicture}[scale = 4]
\draw (0.445041,0.801937) rectangle (0,1) node[midway] {$1$};
\draw (0.692021,0.356896) rectangle (1,1) node[midway] {$2$};
\draw (0.692021,0.356895) rectangle (0,0) node[midway] {$3$};
\draw (0.137063,0.158832) rectangle (0,1) node[midway] {$4$};
\draw (0.384043,0.713791) rectangle (1,0) node[midway] {$5$};
\draw (0.829084,0.515727) rectangle (0,1) node[midway] {$6$};
\draw (0.521105,0.872622) rectangle (0,0) node[midway] {$7$};
\end{tikzpicture}
{M1}
\end{document}