我想要:
- 在页面底部有一个浮动图像,延伸至文本和边缘。
- 在浮动图上方的边距处有文本。这只是纯文本,而不是带有图号的标题。
- 让主要文本位于页面下方,刚好位于浮动图像的上方。
在我的 MWE 中,正文文本停在页边距中的文本顶部。我希望它停在浮动图像之前。覆盖所附屏幕截图中的蓝色箭头。一个简单的解决方案更好。这是我的第一篇文章。
我还尝试在浮动图像中放置边注。这有效。我可以将边注的底部抬高到正确的位置,但我必须用眼睛来做这件事,所以这不是一个实用的解决方案。我试过 wrapfig,但没有用。
\documentclass[oneside]{scrbook} % using book here does not work
\usepackage{graphicx}
\usepackage{kantlipsum}
\usepackage{marginnote}
\usepackage[a4paper,left=20mm,top=25mm,headsep=2\baselineskip,textwidth=100mm,marginparsep=10mm,marginparwidth=50mm,textheight=49\baselineskip,headheight=\baselineskip,showframe]{geometry}
\renewcommand{\bottomfraction}{0.8}
\renewcommand{\topfraction}{0.8}
\renewcommand\bottomfraction{0.8}
\renewcommand\topfraction{0.8}
\renewcommand\textfraction{0.1}
\setcounter{topnumber}{8}
\setcounter{bottomnumber}{8}
\setcounter{totalnumber}{8}
\begin{document}
\begin{figure}[b]
\hspace{110mm}
\begin{minipage}[t]{50mm}
Smart code completion, contextual hover information, and issue reports require the TexLab Language Server. The easiest way to install TexLab is to first install Homebrew and then run brew install texlab in a terminal. If no language server is installed or the path provided in this extension’s Preferences tab is incorrect.
\end{minipage}
\end{figure}
\begin{figure}[b]
\includegraphics[width=160mm]{example-image-a}
\end{figure}
\kant[1-2]
\end{document}
答案1
这计算所需的垂直调整量\marginnote
。
首先,它在保存框中格式化标题。是的,即使标题移动到了新页面,您也可以在保存框中使用\caption
和。它用于将基线移动到图形的顶部,因为是相对于基线放置的。\label
\raisebox
\marginnote
删除\makebox
了过满\hbox
警告。
\documentclass[oneside]{scrbook} % using book here does not work
\usepackage{graphicx}
\usepackage{kantlipsum}
\usepackage{marginnote}
\usepackage[a4paper,left=20mm,top=25mm,headsep=2\baselineskip,textwidth=100mm,marginparsep=10mm,marginparwidth=50mm,textheight=49\baselineskip,headheight=\baselineskip,showframe]{geometry}
\renewcommand{\bottomfraction}{0.8}
\renewcommand{\topfraction}{0.8}
\renewcommand\bottomfraction{0.8}
\renewcommand\topfraction{0.8}
\renewcommand\textfraction{0.1}
\setcounter{topnumber}{8}
\setcounter{bottomnumber}{8}
\setcounter{totalnumber}{8}
\usepackage{marginnote}
\begin{document}
\begin{figure}[b]
\sbox0{\begin{minipage}[b]{\marginparwidth}
Smart code completion, contextual hover information, and issue reports require the TexLab Language Server. The easiest way to install TexLab is to first install Homebrew and then run brew install texlab in a terminal. If no language server is installed or the path provided in this extension’s Preferences tab is incorrect.
\end{minipage}}% measure hgith of caption
\edef\marginnotevadjust{-\the\ht0}%
\marginnote{\usebox0}%
\makebox[\textwidth][l]{\raisebox{-\height}{\includegraphics[width=160mm]{example-image-a}}}
\end{figure}
\kant[1-2]
\end{document}
此版本使用\rlap
和\raisebox
来重叠浮动上方的 marginpar 区域。无需\marginnote
或 savebox。
\documentclass[oneside]{scrbook} % using book here does not work
\usepackage{graphicx}
\usepackage{kantlipsum}
\usepackage{marginnote}
\usepackage[a4paper,left=20mm,top=25mm,headsep=2\baselineskip,textwidth=100mm,marginparsep=10mm,marginparwidth=50mm,textheight=49\baselineskip,headheight=\baselineskip,showframe]{geometry}
\renewcommand{\bottomfraction}{0.8}
\renewcommand{\topfraction}{0.8}
\renewcommand\bottomfraction{0.8}
\renewcommand\topfraction{0.8}
\renewcommand\textfraction{0.1}
\setcounter{topnumber}{8}
\setcounter{bottomnumber}{8}
\setcounter{totalnumber}{8}
\begin{document}
\begin{figure}[b]
\leavevmode\rlap{\hskip\textwidth\hskip\marginparsep
\raisebox{\depth}[0pt][0pt]{\begin{minipage}{\marginparwidth}
Smart code completion, contextual hover information, and issue reports require the TexLab Language Server. The easiest way to install TexLab is to first install Homebrew and then run brew install texlab in a terminal. If no language server is installed or the path provided in this extension’s Preferences tab is incorrect.\strut
\end{minipage}}}%
\makebox[\textwidth][l]{\raisebox{-\height}{\includegraphics[width=160mm]{example-image-a}}}
\end{figure}
\kant[1-2]
\end{document}
答案2
这是一个临时解决方案,但它确实有效。我在页面底部有一个浮动,带有一个图像和一个边注。我将边注的顶部放置在图像上方相当高的位置,然后用一个相当高的迷你页面填充它,迷你页面的底部位于图片上方。我使用其 [b] 内部位置选项将边注文本放到迷你页面的底部。
但我希望看到一个更好的解决方案。
\documentclass[oneside]{scrbook} % using book here does not work
\usepackage{graphicx}
\usepackage{kantlipsum}
\usepackage{marginnote}
\usepackage[a4paper,left=20mm,top=25mm,headsep=2\baselineskip,textwidth=100mm,marginparsep=10mm,marginparwidth=50mm,textheight=49\baselineskip,headheight=\baselineskip,showframe]{geometry}
\renewcommand{\bottomfraction}{0.8}
\renewcommand{\topfraction}{0.8}
\renewcommand\bottomfraction{0.8}
\renewcommand\topfraction{0.8}
\renewcommand\textfraction{0.1}
\setcounter{topnumber}{8}
\setcounter{bottomnumber}{8}
\setcounter{totalnumber}{8}
\begin{document}
\begin{figure}[b]
\marginnote{
\begin{minipage}[t][80mm][b]{\marginparwidth}%
\raggedright Smart code completion, contextual hover information, and issue reports require the TexLab Language Server. The easiest way to install TexLab is to first install Homebrew and then run brew install texlab in a terminal. \end{minipage}
}[-90mm]%
\includegraphics[width=160mm]{example-image-a}
\end{figure}
\kant[1-2]
\end{document}
如果标题应该放在图像下方,则无需调整基线,只需将整个内容放入一个大页面中即可。
\documentclass[oneside]{scrbook} % using book here does not work
\usepackage{graphicx}
\usepackage{kantlipsum}
\usepackage{marginnote}
\usepackage[a4paper,left=20mm,top=25mm,headsep=2\baselineskip,textwidth=100mm,marginparsep=10mm,marginparwidth=50mm,textheight=49\baselineskip,headheight=\baselineskip,showframe]{geometry}
\renewcommand{\bottomfraction}{0.8}
\renewcommand{\topfraction}{0.8}
\renewcommand\bottomfraction{0.8}
\renewcommand\topfraction{0.8}
\renewcommand\textfraction{0.1}
\setcounter{topnumber}{8}
\setcounter{bottomnumber}{8}
\setcounter{totalnumber}{8}
\begin{document}
\begin{figure}[b]
\makebox[\textwidth][l]{\begin{minipage}{\dimexpr \textwidth+\marginparsep+\marginparwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{Smart code completion, contextual hover information, and issue reports require the TexLab Language Server. The easiest way to install TexLab is to first install Homebrew and then run brew install texlab in a terminal. If no language server is installed or the path provided in this extension’s Preferences tab is incorrect.}
\end{minipage}}
\end{figure}
\kant[1-2]
\end{document}