Tạo con số lề rộng hơn lề
Tôi đang sử dụng lớp Tufte và tôi muốn tạo một con số lề lớn hơn lề, làm cho văn bản bao quanh nó. Bất kỳ lời khuyên về cách tôi có thể làm điều đó? Tôi đã thử điều chỉnh @tufte@margin@floatboxđể có được đối số thứ ba cho chiều rộng trang nhỏ, nhưng tôi thất bại thảm hại. Đây là những gì tôi nhận được cho đến nay:
\newsavebox{\myfloatboxwider}
\newenvironment{myfloatwider}[3][-1.2ex]%
{\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.
\begin{lrbox}{\myfloatboxwider}%
\hspace*{-\marginparwidth}%
\begin{minipage}{#3}%
\@tufte@caption@font%
\def\@captype{#2}%
\hbox{}\vspace*{#1}%
\@tufte@caption@justification%
\@tufte@margin@par%
\noindent%
}
{\end{minipage}%
\end{lrbox}%
\marginpar{\usebox{\myfloatboxwider}}%
}
\newenvironment{marginfigurewider}[2][-1.2ex]%
{\begin{myfloatwider}[#1]{figure}{#2}}
{\end{myfloatwider}}
Để sử dụng như thế này
\begin{marginfigurewider}[1.2ex]{2.0\marginparwidth}%
\includegraphics[width=\linewidth]{myimage.jpg}
\caption{Some caption.}
\label{fig:somefig}
\end{marginfigurewider}
Tuy nhiên, có hai vấn đề còn lại mà tôi không thể giải quyết:
- Hspace thực sự nên là như vậy
#3-\marginparwidth, nhưng tôi không thể tìm ra cách thực hiện phép tính này. - Văn bản chính không bao quanh nó. Tôi có cần một cái gì đó như thế
wrapfignày?
Cập nhật
Điều này ít nhiều đạt được những gì tôi muốn:
\setlength\columnsep{\marginparsep}
\begin{wrapfigure}{O}[\dimexpr \marginparwidth+\marginparsep]{2.0\marginparwidth}
\FloatBarrier%
\vspace{-0.7\baselineskip}
\begin{minipage}[b]{2.0\marginparwidth}
\includegraphics[width=\linewidth]{myimage.jpg}
\caption{Some caption.}
\label{fig:somefig}
\end{minipage}
\end{wrapfigure}
Vẫn còn hai vấn đề:
- Các ghi chú bên lề, giống như
cite, được phủ lên hình ảnh, không trôi xuống bên dưới hình ảnh. - Tôi không thể làm cho nó hoạt động như một môi trường mới. Không có gì hiển thị và
width=\linewidthđược gắn cờ là không phải số. Tôi có thể sống bằng cách sử dụng mã theo cách thủ công, nhưng sẽ đẹp hơn nếu đó là một môi trường. Dưới đây là cố gắng:
\newenvironment{marginfigurewide}[1]%
{\FloatBarrier%
\setlength\columnsep{\marginparsep}%
\begin{wrapfigure}{O}[\dimexpr \marginparwidth+\marginparsep]{2.0\marginparwidth}%
\vspace{-0.7\baselineskip}%
\begin{minipage}[b]{2.0\marginparwidth}
}
{\end{minipage}%
\end{wrapfigure}
}
Trả lời
Tôi đã có một ý tưởng sáng tạo về việc dành khoảng trống trong lề bằng cách sử dụng \marginpar. Tuy nhiên, wrapfigure sẽ vẫn chồng lên bất kỳ tài liệu lề nào đã có từ trước. Tôi không biết có cách nào để trì hoãn việc bắt đầu wrapfigure cho đến khi lề trống (ngoại trừ thủ công).
Ngoài ra, tôi không biết tại sao \wrapfigurehoạt động và \begin{wrapfigure}không, nhưng nó có thể liên quan đến giá trị cục bộ so với toàn cầu.
\documentclass{tufte-book}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{marginfix}
\usepackage{lipsum}
\usepackage{showframe}
\newsavebox{\marginbox}
\makeatletter
\newenvironment{marginfigurewide}[1]% #1 = width
{\begin{lrbox}{\marginbox}%
\def\@captype{figure}%
\begin{minipage}{#1}}%
{\end{minipage}\end{lrbox}%
%\setlength{\intextsep}{0pt}%
\setlength{\columnsep}{\marginparsep}%
\wrapfigure{r}[\dimexpr \marginparwidth+\marginparsep]{\wd\marginbox}
\usebox\marginbox
\endwrapfigure
\marginpar{\rule{0pt}{\dimexpr \ht\marginbox+\dp\marginbox+2\intextsep}}}% reserve space in margin
\makeatother
\begin{document}
\begin{marginfigurewide}{2\marginparwidth}
\includegraphics[width=\linewidth]{example-image}
\caption{Some caption.}
\label{fig:somefig}
\end{marginfigurewide}
test\sidenote{\LipsumPar{2}}
\LipsumPar{1}
\end{document}
Phiên bản sẽ chồng lên cuối trang.
\documentclass[twoside]{tufte-book}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{marginfix}
\usepackage{lipsum}
\usepackage{showframe}
\newsavebox{\marginbox}
\makeatletter
\newenvironment{marginfigurewide}[1]% #1 = width
{\begin{lrbox}{\marginbox}%
\def\@captype{figure}%
\begin{minipage}{#1}}%
{\end{minipage}\end{lrbox}%
\setlength{\columnsep}{\marginparsep}%
\dimen0=\dimexpr \pagegoal-\pagetotal-\ht\strutbox\relax% remaining space on page
\dimen1=\dimexpr \ht\marginbox+\dp\marginbox+\intextsep\relax% size of figure
\ifdim\dimen1<\dimen0% fits page
\wrapfigure{r}[\dimexpr \marginparwidth+\marginparsep]{\wd\marginbox}
\usebox\marginbox
\endwrapfigure
\marginpar{\rule{0pt}{\dimexpr \ht\marginbox+\dp\marginbox+2\intextsep}}% reserve space in margin
\else% overlaps bottom
\wrapfigure{r}[\dimexpr \marginparwidth+\marginparsep]{\wd\marginbox}
\raisebox{\dimexpr \dimen0-\intextsep-\ht\marginbox}[\dimexpr \dimen0-2\intextsep][0pt]{\usebox\marginbox}%
\endwrapfigure
\marginpar{\rule{0pt}{\dimen0}}%
\fi}
\makeatother
\begin{document}
\begin{marginfigurewide}{2\marginparwidth}
\includegraphics[width=\linewidth]{example-image}
\caption{Some caption.}
\label{fig:somefig}
\end{marginfigurewide}
Place note here.\sidenote{\LipsumPar{2}}
%\LipsumPar{1}
\lipsum[1-2]
\begin{marginfigurewide}{2\marginparwidth}
\includegraphics[width=\linewidth]{example-image}
\caption{Some caption.}
\label{fig:somefig}
\end{marginfigurewide}
Place note here.\sidenote{\LipsumPar{2}}
\lipsum[3-4]
\end{document}