正确地将 tikz 图形包裹在表格旁边

正确地将 tikz 图形包裹在表格旁边

我正在尝试找到一种方法来正确地将表格放在表格旁边,我发现了这一点,但是改变第一个值textwidth却没有得到想要的结果。我希望这两个物体居中,因为它们是一个独特的物体,但正如您在图片中看到的,它们更靠近右侧。我认为我的错误与环境有关minipage,但不明白如何解决。

在此处输入图片描述

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{geometry}
\geometry{a4paper,top=2cm,bottom=3cm,left=2.5cm,right=3cm,% per regolare i bordi a piacimento
heightrounded,bindingoffset=5mm}
\usepackage{amsmath} % per poter usare le lettere calligrafiche
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{graphicx} % per inserire immagini
\usepackage{tikz}
\usepackage{wrapfig} % per scrivere di fianco alle immagini
\usepackage{gensymb}

\begin{document}

\begin{table}[h]
\begin{minipage}{0.4\textwidth}
\centering
\begin{tikzpicture}
\draw [->] (0,0) -- (3,0);
\draw [->] (0,0) -- (0,2.2);
\draw (2,0) arc [start angle=0,end angle=90,radius=2cm];
\draw (0,0) -- (2.6,2) node [above] {T};
\draw (-0.2,2) node [above] {S} -- (3,2) node [right] {$t$};
\draw (0.5,0) arc [start angle=0,end angle=37,radius=0.5cm];
\draw (-0.2,-0.2) node {O};
\draw (0.7,0.2) node {$\alpha$};
\draw [dashed] (1.58,1.21) node [right] {P}-- (0,1.21) node [left] {R};
\draw (2.6,0) node [below] {$x_T$};
\draw [red,thick] (0,0) -- (2.6,0);
\draw [dashed] (2.6,2) -- (2.6,0);
\end{tikzpicture}
\end{minipage}
%\begin{minipage}{0.2\textwidth}
\centering
\begin{tabular}{l|lllllll}
$\alpha$ & 0\degree & 30\degree & 45\degree & 60\degree & 90\degree & 180\degree & 270\degree\\
\hline
$\tan\alpha$ & 0 & $\frac{\sqrt{3}}{3}$ & 1 & $\sqrt{3}$ & $\nexists$ & 0 & $\nexists$\\
\hline
$\cot\alpha$ & $\nexists$ & $\sqrt{3}$ & 1 & $\frac{\sqrt{3}}{3}$ & 0 & $\nexists$ & 0
\end{tabular}
%\end{minipage}
\end{table}

\end{document}

答案1

全部删除minipage,将 设置baseline为,并在 之前添加tikzpicture一个。您可以使用 增加图表和表格之间的空间。增加可能会稍微改善表格,在分数和s 之间留出一些额外的空间。\centering\begin{tikzpicture}\hspace{<length>}\arraystretch\hline

(图像中的框架是由于showframe的选项而产生的geometry。)

代码输出

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{geometry}
\geometry{
  showframe, % to show the extent of the text area etc.
  a4paper,top=2cm,bottom=3cm,left=2.5cm,right=3cm,% per regolare i bordi a piacimento
heightrounded,bindingoffset=5mm}
\usepackage{amssymb}
\usepackage{mathtools} % loads amsmath
\usepackage{tikz} % loads graphicx
\usepackage{gensymb}

\begin{document}

\begin{table}[h]
\renewcommand\arraystretch{1.5}
\centering
\begin{tikzpicture}[baseline=(current bounding box.center)]
\draw [->] (0,0) -- (3,0);
\draw [->] (0,0) -- (0,2.2);
\draw (2,0) arc [start angle=0,end angle=90,radius=2cm];
\draw (0,0) -- (2.6,2) node [above] {T};
\draw (-0.2,2) node [above] {S} -- (3,2) node [right] {$t$};
\draw (0.5,0) arc [start angle=0,end angle=37,radius=0.5cm];
\draw (-0.2,-0.2) node {O};
\draw (0.7,0.2) node {$\alpha$};
\draw [dashed] (1.58,1.21) node [right] {P}-- (0,1.21) node [left] {R};
\draw (2.6,0) node [below] {$x_T$};
\draw [red,thick] (0,0) -- (2.6,0);
\draw [dashed] (2.6,2) -- (2.6,0);
\end{tikzpicture}\hspace{5mm}
\begin{tabular}{l|lllllll}
$\alpha$ & 0\degree & 30\degree & 45\degree & 60\degree & 90\degree & 180\degree & 270\degree\\
\hline
$\tan\alpha$ & 0 & $\frac{\sqrt{3}}{3}$ & 1 & $\sqrt{3}$ & $\nexists$ & 0 & $\nexists$\\
\hline
$\cot\alpha$ & $\nexists$ & $\sqrt{3}$ & 1 & $\frac{\sqrt{3}}{3}$ & 0 & $\nexists$ & 0
\end{tabular}
\end{table}
\end{document}

相关内容