我想删除 Beamer 幻灯片上两列之间的多余空间。一列中有图表,另一列中有表格。我希望幻灯片上的图表和表格更靠近一点。谢谢。
\documentclass[aspectratio=169]{beamer} % wide frame
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{positioning}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{frame}{Corpus size}
\begin{columns}[T]
\begin{column}{0.5\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
every axis plot post/.style={/pgf/number format/fixed},
ybar,
bar width=.1\textwidth,
height=.55\textwidth, % Adjust the height of the axis to fit within the frame
ymin=0,
enlarge x limits=.5, % this controls the blank space to the left and to the right, but needs these two lines below:
% xmin={Texts}, %
xmax={Words}, %
ymax=1500, % this is where the y axis stops and the wavy line is drawn
xtick=data,
symbolic x coords={Texts,Words},
restrict y to domain*=0:1700, % Cut values off here, has to be higher than ymax
visualization depends on=rawy\as\rawy, % Save the unclipped values
after end axis/.code={ % Draw line indicating break
\draw [ultra thick, white, decoration={snake, amplitude=2pt}, decorate] (rel axis cs:0,1) -- (rel axis cs:2,1);
},
nodes near coords={%
\pgfmathprintnumber{\rawy}% Print unclipped values
},
axis lines*=left, % this is where the wavy line is drawn, but it is hidden
clip=false
]
\addplot [fill=orange!50] coordinates {(Texts,1117) (Words,5601719)};
\end{axis}
\end{tikzpicture}
\end{column}
%
\begin{column}{0.5\textwidth}
\centering
\small
\begin{tabular}{ccc} \hline
Subcorpus & Texts & Words \\ \hline \hline
Pseudo & 117 & 1000000 \\
Science & 1000 & 4000000 \\ \hline
\end{tabular}
\end{column}
\end{columns}
\end{frame}
\end{document}
答案1
图像和表格之间的空白是两种不同效果的组合:
默认情况下,Beamer 会更改列的页边距以在列之间留出一些空间。这很容易避免:您只需使用
onlytextwidth
选项第二个因素是,您的图片和表格比列的宽度小得多。您还将它们居中,从而在它们之间留出空间。为了避免这种情况,您可以 a) 缩小左列,扩大右列,以及 b) 删除居中,以便您的图片和表格在列内左对齐。
\documentclass[aspectratio=169]{beamer} % wide frame
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{positioning}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{frame}{Corpus size}
\begin{columns}[T,onlytextwidth]
\begin{column}{0.4\textwidth}
\begin{tikzpicture}
\begin{axis}[
every axis plot post/.style={/pgf/number format/fixed},
ybar,
bar width=0.7cm,
height=.45\textheight, % Adjust the height of the axis to fit within the frame
ymin=0,
enlarge x limits=.5, % this controls the blank space to the left and to the right, but needs these two lines below:
% xmin={Texts}, %
xmax={Words}, %
ymax=1500, % this is where the y axis stops and the wavy line is drawn
xtick=data,
symbolic x coords={Texts,Words},
restrict y to domain*=0:1700, % Cut values off here, has to be higher than ymax
visualization depends on=rawy\as\rawy, % Save the unclipped values
after end axis/.code={ % Draw line indicating break
\draw [ultra thick, white, decoration={snake, amplitude=2pt}, decorate] (rel axis cs:0,1) -- (rel axis cs:2,1);
},
nodes near coords={%
\pgfmathprintnumber{\rawy}% Print unclipped values
},
axis lines*=left, % this is where the wavy line is drawn, but it is hidden
clip=false
]
\addplot [fill=orange!50] coordinates {(Texts,1117) (Words,5601719)};
\end{axis}
\end{tikzpicture}
\end{column}
%
\begin{column}{0.6\textwidth}
\small
\begin{tabular}{ccc} \hline
Subcorpus & Texts & Words \\ \hline \hline
Pseudo & 117 & 1000000 \\
Science & 1000 & 4000000 \\ \hline
\end{tabular}
\end{column}
\end{columns}
\end{frame}
\end{document}
答案2
问题出在这一行:
\draw [ultra thick, white, decoration={snake, amplitude=2pt}, decorate] (rel axis cs:0,1) -- (rel axis cs:2,1);
这导致波浪线向右延伸得比需要的更远,而且由于该线是白色绘制的,因此看不到其长度。
这些坐标解决了问题:
\draw [ultra thick, white, decoration={snake, amplitude=2pt}, decorate] (rel axis cs:0,1) -- (rel axis cs:1,1);
固定幻灯片:
\documentclass[aspectratio=169]{beamer} % wide frame
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{positioning}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{frame}{Corpus size}
\begin{columns}[T]
\begin{column}{0.5\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
every axis plot post/.style={/pgf/number format/fixed},
ybar,
bar width=.1\textwidth,
height=.55\textwidth, % Adjust the height of the axis to fit within the frame
ymin=0,
enlarge x limits=.5, % this controls the blank space to the left and to the right, but needs these two lines below:
% xmin={Texts}, %
xmax={Words}, %
ymax=1500, % this is where the y axis stops and the wavy line is drawn
xtick=data,
symbolic x coords={Texts,Words},
restrict y to domain*=0:1700, % Cut values off here, has to be higher than ymax
visualization depends on=rawy\as\rawy, % Save the unclipped values
after end axis/.code={ % Draw line indicating break
\draw [ultra thick, white, decoration={snake, amplitude=2pt}, decorate] (rel axis cs:0,1) -- (rel axis cs:1,1);
},
nodes near coords={%
\pgfmathprintnumber{\rawy}% Print unclipped values
},
axis lines*=left, % this is where the wavy line is drawn, but it is hidden
clip=false
]
\addplot [fill=orange!50] coordinates {(Texts,1117) (Words,5601719)};
\end{axis}
\end{tikzpicture}
\end{column}
%
\begin{column}{0.5\textwidth}
\centering
\small
\begin{tabular}{ccc} \hline
Subcorpus & Texts & Words \\ \hline \hline
Pseudo & 117 & 1000000 \\
Science & 1000 & 4000000 \\ \hline
\end{tabular}
\end{column}
\end{columns}
\end{frame}
\end{document}