![Tikz 水平对齐](https://linux22.com/image/287812/Tikz%20%E6%B0%B4%E5%B9%B3%E5%AF%B9%E9%BD%90.png)
我已经准备好页边距,但是我需要水平对齐三个 Tikz 图形,三个图形的宽度大于 what\textwidth
但小于 what \textwidth
+ marginpar。
我怎样才能将三个图形定位在此处而不修改边距?
\documentclass[11pt]{book}
%\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[letterpaper
,inner=.75in
,top=.5in
,bottom=.5in
,includeheadfoot
,textwidth=5in
,marginparwidth=2in
,marginparsep=0.25in
,showframe]{geometry}
\usepackage{subfig}
\usepackage{float}
\usepackage{tikz}
\usepackage{pgf}
\usepackage{pgffor}
\usepgfmodule{shapes}
\usepgfmodule{plot}
\usetikzlibrary{decorations}
\usetikzlibrary{datavisualization}
\usetikzlibrary{arrows}
\usetikzlibrary{patterns}
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{through}
\usepackage[usenames,dvipsnames]{pstricks}
\usepackage{epsfig}
\usepackage{pst-grad} % For gradients
\usepackage{pst-plot} % For axes
\begin{document}
\begin{figure}[H]
\subfloat[]{
\begin{tikzpicture}[scale=.6]
\useasboundingbox(-2.5,-2) rectangle (7,8.5);
\draw[->] (0,0,0) -- (xyz cs:x=6);
\draw[->] (0,0,0) -- (xyz cs:y=6);
\draw[->] (0,0,0) -- (xyz cs:z=4);
\node[right=3pt,inner sep=0, outer sep=0] at (6,0,0) (x) {$x$};
\node[above=3pt,inner sep=0, outer sep=0] at (0,6,0) (y) {$y$};
\node[below=3pt,inner sep=0, outer sep=0] at (0,0,4) (z) {$z$};
\node[inner sep=0, outer sep=0] at (1,2) (a) {};
\node[inner sep=0, outer sep=0] at (2,3.5) (b) {};
\node[inner sep=0, outer sep=0] at (2.5,5) (c) {};
\node[inner sep=0, outer sep=0] at (3.5,4.5) (d) {};
\node[inner sep=0, outer sep=0] at (4,2.5) (e) {};
\node[inner sep=0, outer sep=0] at (3,1) (f) {};
\shadedraw[inner color=brown!10,outer color=brown!80,draw=brown!80]
plot [smooth cycle, tension=.8] coordinates { (a) (b) (c) (d) (e) (f)};
\node[inner sep=1pt, outer sep=1pt] (pa) at (3,2) {};
\shade[ball color=green] (pa) circle (.1cm);
\node[inner sep=1pt, outer sep=1pt] (pb) at (2.8,4.5) {};
\shade[ball color=green] (pb) circle (.1cm);
\node[right] at (pa) {$A$};
\node[right] at (pb) {$B$};
\draw[arrows={-latex},color=cyan,ultra thick] (0,0,0) -- node[color=cyan, midway=pt, left=5pt]{$r_{B}$} (pb);
\draw[arrows={-latex},color=cyan,ultra thick] (0,0,0) -- node[color=cyan, midway, left=-25]{$r_{A}$} (pa);
\draw[arrows={-latex},color=cyan!70,ultra thick] (pa) -- node[color=cyan!70, midway, left=-30]{$r_{B/A}$} (pb);
\end{tikzpicture}
}
\subfloat[]{
\begin{tikzpicture}[scale=.6]
%\useasboundingbox (-2.5,-2) rectangle (7,8.5);
\draw[->] (0,0,0) -- (xyz cs:x=6);
\draw[->] (0,0,0) -- (xyz cs:y=6);
\draw[->] (0,0,0) -- (xyz cs:z=4);
\node[right=3pt,inner sep=0, outer sep=0] at (6,0,0) (x) {$x$};
\node[above=3pt,inner sep=0, outer sep=0] at (0,6,0) (y) {$y$};
\node[below=3pt,inner sep=0, outer sep=0] at (0,0,4) (z) {$z$};
\node[inner sep=0, outer sep=0] at (1,2) (a) {};
\node[inner sep=0, outer sep=0] at (2,3.5) (b) {};
\node[inner sep=0, outer sep=0] at (2.5,5) (c) {};
\node[inner sep=0, outer sep=0] at (3.5,4.5) (d) {};
\node[inner sep=0, outer sep=0] at (4,2.5) (e) {};
\node[inner sep=0, outer sep=0] at (3,1) (f) {};
\shadedraw[inner color=brown!10,outer color=brown!80,draw=brown!80]
plot [smooth cycle, tension=.8] coordinates { (a) (b) (c) (d) (e) (f)};
%\draw plot [smooth , tension=.8,color=cyan,ultra thick] coordinates { (1,1.5) (pa) (5,3)};
\draw[cyan,ultra thick] plot [smooth , tension=.8] coordinates { (1,2) (pa) (5.2,3.2)};
\draw[cyan,ultra thick] plot [smooth , tension=.8] coordinates { (1,4.5) (pb) (5,5.7)};
\node[inner sep=1pt, outer sep=1pt] (pa) at (3,2) {};
\shade[ball color=green] (pa) circle (.1cm);
\node[inner sep=1pt, outer sep=1pt] (pb) at (2.8,4.5) {};
\shade[ball color=green] (pb) circle (.1cm);
\node[above] at (pa) {$A$};
\node[above] at (pb) {$B$};
\draw[arrows={-latex},color=green!80!red!80!blue!80,ultra thick] (pb) -- node[color=green!80!blue!80!red!80, midway, below]{$V$} (5,5);
\draw[arrows={-latex},color=green!80!blue!80!red!80,ultra thick] (pa) -- node[color=green!80!blue!80!red!80, midway, below]{$V$} (5.2,2.5);
\end{tikzpicture}
}
\subfloat[]{
\begin{tikzpicture}[scale=.6]
%\useasboundingbox (-2.5,-2) rectangle (7,8.5);
\draw[->] (0,0,0) -- (xyz cs:x=6);
\draw[->] (0,0,0) -- (xyz cs:y=6);
\draw[->] (0,0,0) -- (xyz cs:z=4);
\node[right=3pt,inner sep=0, outer sep=0] at (6,0,0) (x) {$x$};
\node[above=3pt,inner sep=0, outer sep=0] at (0,6,0) (y) {$y$};
\node[below=3pt,inner sep=0, outer sep=0] at (0,0,4) (z) {$z$};
\node[inner sep=0, outer sep=0] at (1,2) (a) {};
\node[inner sep=0, outer sep=0] at (2,3.5) (b) {};
\node[inner sep=0, outer sep=0] at (2.5,5) (c) {};
\node[inner sep=0, outer sep=0] at (3.5,4.5) (d) {};
\node[inner sep=0, outer sep=0] at (4,2.5) (e) {};
\node[inner sep=0, outer sep=0] at (3,1) (f) {};
\shadedraw[inner color=brown!10,outer color=brown!80,draw=brown!80]
plot [smooth cycle, tension=.8] coordinates { (a) (b) (c) (d) (e) (f)};
%\draw plot [smooth , tension=.8,color=cyan,ultra thick] coordinates { (1,1.5) (pa) (5,3)};
\draw[cyan,ultra thick] plot [smooth , tension=.8] coordinates { (1,2) (pa) (5.2,3.2)};
\draw[cyan,ultra thick] plot [smooth , tension=.8] coordinates { (1,4.5) (pb) (5,5.7)};
\node[inner sep=1pt, outer sep=1pt] (pa) at (3,2) {};
\shade[ball color=green] (pa) circle (.1cm);
\node[inner sep=1pt, outer sep=1pt] (pb) at (2.8,4.5) {};
\shade[ball color=green] (pb) circle (.1cm);
\node[above] at (pa) {$A$};
\node[above] at (pb) {$B$};
\draw[arrows={-latex},color=red!80,ultra thick] (pb) -- node[color=red!80, near end, below]{$a$} (1,5.5);
\draw[arrows={-latex},color=red!80,ultra thick] (pa) -- node[color=red!80, near end, below]{$a$} (1.7,3);
\end{tikzpicture}
}
%\caption{dasdasdasd}
\end{figure}
\end{document}
答案1
您可以通过删除虚假空格来实现这一点:
笔记:
- 根据@TorbjørnT.的建议,我添加了使用包裹
changepage
消除该Overfull \hbox
消息。
代码:
\documentclass[11pt]{book}
%\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[letterpaper
,inner=.75in
,top=.5in
,bottom=.5in
,includeheadfoot
,textwidth=5in
,marginparwidth=2in
,marginparsep=0.25in
,showframe]{geometry}
\usepackage{changepage}
\usepackage{subfig}
\usepackage{float}
\usepackage{tikz}
%\usepackage{pgf}
%\usepackage{pgffor} %% These are not necessary for this MWE
%\usepgfmodule{shapes}
%\usepgfmodule{plot}
%\usetikzlibrary{decorations}
%\usetikzlibrary{datavisualization}
%\usetikzlibrary{arrows}
%\usetikzlibrary{patterns}
%\usetikzlibrary{calc}
%\usetikzlibrary{intersections}
% \usetikzlibrary{through}
%\usepackage[usenames,dvipsnames]{pstricks}
% \usepackage{epsfig}
%\usepackage{pst-grad} % For gradients
% \usepackage{pst-plot} % For axes
\begin{document}
\begin{figure}[H]
\begin{adjustwidth}{0pt}{-83pt}
\subfloat[]{% <---- Added %
\begin{tikzpicture}[scale=.6]
\useasboundingbox(-2.5,-2) rectangle (7,8.5);
\draw[->] (0,0,0) -- (xyz cs:x=6);
\draw[->] (0,0,0) -- (xyz cs:y=6);
\draw[->] (0,0,0) -- (xyz cs:z=4);
\node[right=3pt,inner sep=0, outer sep=0] at (6,0,0) (x) {$x$};
\node[above=3pt,inner sep=0, outer sep=0] at (0,6,0) (y) {$y$};
\node[below=3pt,inner sep=0, outer sep=0] at (0,0,4) (z) {$z$};
\node[inner sep=0, outer sep=0] at (1,2) (a) {};
\node[inner sep=0, outer sep=0] at (2,3.5) (b) {};
\node[inner sep=0, outer sep=0] at (2.5,5) (c) {};
\node[inner sep=0, outer sep=0] at (3.5,4.5) (d) {};
\node[inner sep=0, outer sep=0] at (4,2.5) (e) {};
\node[inner sep=0, outer sep=0] at (3,1) (f) {};
\shadedraw[inner color=brown!10,outer color=brown!80,draw=brown!80]
plot [smooth cycle, tension=.8] coordinates { (a) (b) (c) (d) (e) (f)};
\node[inner sep=1pt, outer sep=1pt] (pa) at (3,2) {};
\shade[ball color=green] (pa) circle (.1cm);
\node[inner sep=1pt, outer sep=1pt] (pb) at (2.8,4.5) {};
\shade[ball color=green] (pb) circle (.1cm);
\node[right] at (pa) {$A$};
\node[right] at (pb) {$B$};
\draw[arrows={-latex},color=cyan,ultra thick] (0,0,0) -- node[color=cyan, midway=pt, left=5pt]{$r_{B}$} (pb);
\draw[arrows={-latex},color=cyan,ultra thick] (0,0,0) -- node[color=cyan, midway, left=-25]{$r_{A}$} (pa);
\draw[arrows={-latex},color=cyan!70,ultra thick] (pa) -- node[color=cyan!70, midway, left=-30]{$r_{B/A}$} (pb);
\end{tikzpicture}% <---- Added %
}% <---- Added %
\subfloat[]{% <---- Added %
\begin{tikzpicture}[scale=.6]
%\useasboundingbox (-2.5,-2) rectangle (7,8.5);
\draw[->] (0,0,0) -- (xyz cs:x=6);
\draw[->] (0,0,0) -- (xyz cs:y=6);
\draw[->] (0,0,0) -- (xyz cs:z=4);
\node[right=3pt,inner sep=0, outer sep=0] at (6,0,0) (x) {$x$};
\node[above=3pt,inner sep=0, outer sep=0] at (0,6,0) (y) {$y$};
\node[below=3pt,inner sep=0, outer sep=0] at (0,0,4) (z) {$z$};
\node[inner sep=0, outer sep=0] at (1,2) (a) {};
\node[inner sep=0, outer sep=0] at (2,3.5) (b) {};
\node[inner sep=0, outer sep=0] at (2.5,5) (c) {};
\node[inner sep=0, outer sep=0] at (3.5,4.5) (d) {};
\node[inner sep=0, outer sep=0] at (4,2.5) (e) {};
\node[inner sep=0, outer sep=0] at (3,1) (f) {};
\shadedraw[inner color=brown!10,outer color=brown!80,draw=brown!80]
plot [smooth cycle, tension=.8] coordinates { (a) (b) (c) (d) (e) (f)};
%\draw plot [smooth , tension=.8,color=cyan,ultra thick] coordinates { (1,1.5) (pa) (5,3)};
\draw[cyan,ultra thick] plot [smooth , tension=.8] coordinates { (1,2) (pa) (5.2,3.2)};
\draw[cyan,ultra thick] plot [smooth , tension=.8] coordinates { (1,4.5) (pb) (5,5.7)};
\node[inner sep=1pt, outer sep=1pt] (pa) at (3,2) {};
\shade[ball color=green] (pa) circle (.1cm);
\node[inner sep=1pt, outer sep=1pt] (pb) at (2.8,4.5) {};
\shade[ball color=green] (pb) circle (.1cm);
\node[above] at (pa) {$A$};
\node[above] at (pb) {$B$};
\draw[arrows={-latex},color=green!80!red!80!blue!80,ultra thick] (pb) -- node[color=green!80!blue!80!red!80, midway, below]{$V$} (5,5);
\draw[arrows={-latex},color=green!80!blue!80!red!80,ultra thick] (pa) -- node[color=green!80!blue!80!red!80, midway, below]{$V$} (5.2,2.5);
\end{tikzpicture}% <---- Added %
}% <---- Added %
% <---- Added %
\subfloat[]{% <---- Added %
\begin{tikzpicture}[scale=.6]
%\useasboundingbox (-2.5,-2) rectangle (7,8.5);
\draw[->] (0,0,0) -- (xyz cs:x=6);
\draw[->] (0,0,0) -- (xyz cs:y=6);
\draw[->] (0,0,0) -- (xyz cs:z=4);
\node[right=3pt,inner sep=0, outer sep=0] at (6,0,0) (x) {$x$};
\node[above=3pt,inner sep=0, outer sep=0] at (0,6,0) (y) {$y$};
\node[below=3pt,inner sep=0, outer sep=0] at (0,0,4) (z) {$z$};
\node[inner sep=0, outer sep=0] at (1,2) (a) {};
\node[inner sep=0, outer sep=0] at (2,3.5) (b) {};
\node[inner sep=0, outer sep=0] at (2.5,5) (c) {};
\node[inner sep=0, outer sep=0] at (3.5,4.5) (d) {};
\node[inner sep=0, outer sep=0] at (4,2.5) (e) {};
\node[inner sep=0, outer sep=0] at (3,1) (f) {};
\shadedraw[inner color=brown!10,outer color=brown!80,draw=brown!80]
plot [smooth cycle, tension=.8] coordinates { (a) (b) (c) (d) (e) (f)};
%\draw plot [smooth , tension=.8,color=cyan,ultra thick] coordinates { (1,1.5) (pa) (5,3)};
\draw[cyan,ultra thick] plot [smooth , tension=.8] coordinates { (1,2) (pa) (5.2,3.2)};
\draw[cyan,ultra thick] plot [smooth , tension=.8] coordinates { (1,4.5) (pb) (5,5.7)};
\node[inner sep=1pt, outer sep=1pt] (pa) at (3,2) {};
\shade[ball color=green] (pa) circle (.1cm);
\node[inner sep=1pt, outer sep=1pt] (pb) at (2.8,4.5) {};
\shade[ball color=green] (pb) circle (.1cm);
\node[above] at (pa) {$A$};
\node[above] at (pb) {$B$};
\draw[arrows={-latex},color=red!80,ultra thick] (pb) -- node[color=red!80, near end, below]{$a$} (1,5.5);
\draw[arrows={-latex},color=red!80,ultra thick] (pa) -- node[color=red!80, near end, below]{$a$} (1.7,3);
\end{tikzpicture}% <---- Added %
}% <---- Added %
%\caption{dasdasdasd}
\end{adjustwidth}
\end{figure}%
\end{document}