![adjustbox는 테이블 및 tikzpicture 너비를 줄이지 않습니다.](https://rvso.com/image/281580/adjustbox%EB%8A%94%20%ED%85%8C%EC%9D%B4%EB%B8%94%20%EB%B0%8F%20tikzpicture%20%EB%84%88%EB%B9%84%EB%A5%BC%20%EC%A4%84%EC%9D%B4%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
학생들이 태블릿, 전자책 리더기 등에서 노트를 읽고 싶어했기 때문에 대학 수업을 위한 강의 노트를 다시 디자인하고 있습니다. 그래서 다양한 페이지 크기에 대해 다양한 대상을 사용하여 Makefile을 작성했습니다. 내가 가진 유일한 문제는 일부 PGF/TikZ 수치와 일부 테이블이 너무 커서 작은 용지 크기에 맞지 않는다는 것입니다.
나는 사용하고 싶습니다adjustbox
PGF/TikZ로 그린 표와 그림이 너무 커서 정의된 용지 크기에 맞지 않는 경우 크기를 줄입니다. 그러나 실제로는 작동하지 않습니다.
\documentclass[10pt]{article}
% set page size with geometry
\usepackage[nohead,%
nofoot,%
nomarginpar,%
paperwidth=106.68mm,%
paperheight=142.24mm,%
tmargin=2.5mm,%
rmargin=2.5mm,%
bmargin=2.5mm,%
lmargin=2.5mm]{geometry}
\usepackage{float}
\usepackage{tikz}
\usepackage{adjustbox}
%define lengths for maximum figure and table width and height
\newlength{\maxtabfigwidth}
\newlength{\maxtabfigheight}
\setlength{\maxtabfigwidth}{\textwidth}
\setlength{\maxtabfigheight}{\textheight}
% decrease height a bit letting captions fit to one page
\addtolength{\maxtabfigheight}{-2.5em}
\pagestyle{empty}
\begin{document}
\section*{Example \#1}
The width of the table isn't reduced to \texttt{\textbackslash{}maxtabfigwidth}.
\begin{adjustbox}{center,%
max width={\maxtabfigwidth},%
max totalheight={\maxtabfigheight},%
captionbelow={A wide table},%
float={table}[h!]}
\begin{tabular}{p{6cm}p{6cm}}
\hline
wide & table \\\hline
\end{tabular}
\end{adjustbox}
\section*{Example \#2}
The width of the tikzpicture isn't reduced to \texttt{\textbackslash{}maxtabfigwidth}.
\begin{adjustbox}{center,%
max width={\maxtabfigwidth},%
max totalheight={\maxtabfigheight},%
captionbelow={A wide tikzpicture},%
float={figure}[H]}
\begin{tikzpicture}
\fill[black] (0cm, 0cm) -- (0cm, -3cm) -- (12cm, -3cm) -- (12cm, 0cm) -- cycle;
\end{tikzpicture}
\end{adjustbox}
\section*{Example \#3}
The height of the tikzpicture is reduced to\texttt{\textbackslash{}maxtabfigheight}, however it is not centered.
\begin{adjustbox}{center,%
max width={\maxtabfigwidth},%
max totalheight={\maxtabfigheight},%
captionbelow={A tall tikzpicture},%
float={figure}[H]}
\begin{tikzpicture}
\fill[black] (0cm, 0cm) -- (0cm, -15cm) -- (5cm, -15cm) -- (5cm, 0cm) -- cycle;
\end{tikzpicture}
\end{adjustbox}
\end{document}
그래서 질문은 내가 무엇을 놓치고 있거나 잘못하고 있습니까? 작은 종이 크기에 맞지 않는 경우 표와 그림을 축소하는 다른 방법이 있습니까?
답변1
두 가지 문제가 있습니다. 첫 번째는 시작 문서에서 계산을 수행하기 때문에 이후 \maxtabfigwidth
의 값을 계산해야 한다는 것입니다 .\maxtabfigheight
geometry
두 번째 문제는 옵션의 순서가 adjustbox
중요하다는 것입니다. 특히 and center
뒤에 와야 합니다 .max width
max totalheight
\documentclass[10pt]{article}
% set page size with geometry
\usepackage[nohead,%
nofoot,%
nomarginpar,%
paperwidth=106.68mm,%
paperheight=142.24mm,%
tmargin=2.5mm,%
rmargin=2.5mm,%
bmargin=2.5mm,%
lmargin=2.5mm]{geometry}
\usepackage{float}
\usepackage{tikz}
\usepackage{adjustbox}
%define lengths for maximum figure and table width and height
\newlength{\maxtabfigwidth}
\newlength{\maxtabfigheight}
\AtBeginDocument{
\setlength{\maxtabfigwidth}{\textwidth}
\setlength{\maxtabfigheight}{\textheight}
% decrease height a bit letting captions fit to one page
\addtolength{\maxtabfigheight}{-2.5em}
}
\pagestyle{empty}
\begin{document}
\section*{Example \#1}
The width of the table isn't reduced to \texttt{\textbackslash{}maxtabfigwidth}.
\begin{adjustbox}{
max width=\maxtabfigwidth,
max totalheight=\maxtabfigheight,
center,
captionbelow={A wide table},
float={table}[h!],
}
\begin{tabular}{p{6cm}p{6cm}}
\hline
wide & table \\\hline
\end{tabular}
\end{adjustbox}
\section*{Example \#2}
The width of the tikzpicture isn't reduced to \texttt{\textbackslash{}maxtabfigwidth}.
\begin{adjustbox}{
max width=\maxtabfigwidth,
max totalheight=\maxtabfigheight,
center,
captionbelow={A wide tikzpicture},%
float={figure}[H],
}
\begin{tikzpicture}
\fill[black] (0cm, 0cm) -- (0cm, -3cm) -- (12cm, -3cm) -- (12cm, 0cm) -- cycle;
\end{tikzpicture}
\end{adjustbox}
\section*{Example \#3}
The height of the tikzpicture is reduced to\texttt{\textbackslash{}maxtabfigheight}, however
it is not centered.
\begin{adjustbox}{
max width=\maxtabfigwidth,
max totalheight=\maxtabfigheight,
center,
captionbelow={A tall tikzpicture},
float={figure}[H],
}
\begin{tikzpicture}
\fill[black] (0cm, 0cm) -- (0cm, -15cm) -- (5cm, -15cm) -- (5cm, 0cm) -- cycle;
\end{tikzpicture}
\end{adjustbox}
\end{document}