我需要使用很多marginpar
s,结果却遇到了“未处理浮点数太多”的错误。我已经在使用设置为 的morefloats
包,但有时还不够。我想一个解决方案可能是强制s 出现在声明它们的位置(就像浮点数的选项一样)。maxfloats
100
marginpar
H
有没有办法做到这一点?
注:我需要浮点数对于我的解决方案,我不能使用固定注释,因为它们必须浮动在边缘,即使插入到段落的中间。
另一个注意事项:\FlatBarrier
来自placeins
包(与 结合morefloats
)有帮助,但我需要找到如何放置它,以便它不会影响我的布局。通常,我只需要\marginpar
在行首调用 时才调用它,这样可能会解决问题。
答案1
笔记:
下面定义的命令\extrafloats
是在 2015 年及以后的 LaTeX 版本中以乳胶格式定义的,因此无需此定义或包即可使用。
morefloats
仅从经典 tex 计数器范围 0-255 中分配浮点数,并且由于 LaTeX 在格式中使用了许多这样的寄存器,因此最多只有大约 100 个,但由于 etex 通常可用,您实际上可以从扩展范围中分配浮点数,因此如果需要的话,可以有大约 32000 个。
这是使用figure
而不是marginpar
,但它们来自同一个池,因此它应该对任一都起作用。
\documentclass{article}
\makeatletter
\mathchardef\float@count=32767
\def\extrafloats#1{%
\ifnum#1>\z@
\count@\numexpr\float@count-1\relax
\mathchardef\float@count\count@
\expandafter\mathchardef\csname bx@\the\float@count\endcsname\float@count
\@cons\@freelist{\csname bx@\the\float@count\endcsname}%
\expandafter
\extrafloats\expandafter{\numexpr#1-1\relax}%
\fi}
\makeatletter
\extrafloats{500}
%\usepackage[maxfloats=100]{morefloats} not enough
\setcounter{totalnumber}{1}
\def\f{text text\par
\begin{figure}[t]\rule{1cm}{1cm}
\caption{fff}\end{figure}}
\def\ff{\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f\f}
\begin{document}
\ff\ff\ff\ff\ff\ff
\ff\ff\ff\ff\ff\ff
\end{document}
答案2
借助 Donald Arseneau 的新 (MAR 13)tabto
软件包改进,您可以立即执行 marginpars。我创建它\imarginpar
就是为了这样做。也许它会有所帮助。此外,没有什么可以阻止您在两个边距中进行 marginpar'ing,只需更改参数即可\tabto
。
\documentclass{article}
\usepackage{tabto}
\newcommand\imarginpar[1]{%
\tabto*{-0.5cm}%
\smash{\llap{\parbox[t]{1in}%
{#1}}}%
\tabto{\TabPrevPos}%
}
\begin{document}
This is blah blahThis is blah blahThis is blah blahThis is blah blahThis
is blah blahThis is blah blahThis is blah blahThis is blah blahThis is
blah blahThis is blah blahThis is blah blahThis is blah blahThis is blah
blahThis is blah blahThis is blah blahThis is blah blahThis is blah
blahThis is blah blahThis is blah blahThis is blah blahThis is blah
is blah blahThis is blah blahThis is blah blahThis is blah
blahThis is blah HERE IS THE TAB \imarginpar{margin note test record}
DONE THE TAB blah This is blah blahThis is blah blahThis is blah
blahThis is blah blahThis is blah blahThis is blah blahThis is blah
blahThis is blah blahThis is blah blahThis is blah blahThis is blah
blahThis is blah blahThis is blah blahThis is blah blah
\end{document}
这是我从 Arseneau 先生那里得到的 tabto 的临时版本,包含新的长度\TabPrevPos
% tabto.sty
%
% version 1.3 (Mar 2013)
%
% Tabbing to fixed positions in a paragraph.
%
% Copyright 2006,2009,2012,2013 by
% Donald Arseneau, Vancouver, Canada ([email protected])
% Permission to use, distribute and modify this software is granted
% under the conditions of the LaTeX Project Public License, either
% version 1.3 or (at your option) any later version. The license is
% found at http://www.latex-project.org/lppl.txt, and is part of all
% recent distributions of LaTeX.
%
% This work has the LPPL maintenance status `maintained' (by author).
%
% Two new text positioning commands are defined: \tabto and \tab.
%
% \tabto{<length>}
% Tab to a position relative to the left margin in a paragraph (any
% indentation due to a list or \leftskip is part of the `margin' in
% this context). If the text on the line already goes past the desired
% position, the tab starts a new line and moves to the requested
% horizontal position.
%
% \tabto*{<length>}
% Similar to \tabto, except it will perform backspacing, and over-
% print previous text on the line whenever that text is already
% longer than the specified length (i.e., no linebreak is produced).
% Line-breaks are suppressed immediately after \tabto or \tabto*.
%
% The length register "\CurrentLineWidth" will report the width
% of the existing text on the line, and it may be used in the
% <length> argument (using calc.sty, for example). Also, there
% is "\TabPrevPos" which gives the "\CurrentLineWidth" from the
% previous tab command, and can be used to return to that position
% if no line breaks have occurred in between.
%
% \tab
% Tab to the next tab-stop chosen from a list of tab positions, in
% the traditional style of typewriters. A \tab will always move
% to the next tab stop (or the next line), even if it is already
% exactly at a tab stop. Thus, "\tab" at the beginning of a line,
% or "\tab\tab" elsewhere skips a position. A linebreak is permitted
% immediately following a \tab, in case the ensuing text does not
% fit well in the remaining space.
%
% If you do not want to skip positions, use "\tabto{\NextTabStop}"
% instead of "\tab". This is particularly useful when you want to
% use \tab in some other command, but do not want to skip a column
% for the first item.
%
% The tab-stop positions are declared using either \TabPositions
% or \NumTabs:
%
% \TabPositions{<length>, <length>,...<length>}
% Declares the tab stops as a comma-separated list of positions
% relative to the left margin. A tab-stop at 0pt is implicit, and
% need not be listed.
%
% \NumTabs{<number>}
% Declares a list of <number> equally-spaced tabs, starting at the
% left margin and spanning \linewidth. For example \NumTabs{2}
% declares tab-stops at 0pt and 0.5\linewidth, the same as
% \TabPositions{0pt, 0.5\linewidth} or \TabPositions{0.5\linewidth}
%
% After these declarations, the list of tab positions is saved in
% \TabStopList, and the next tab position, relative to the current
% position, is given by \NextTabStop. You do not normally need
% to access them, but they are available.
%
% Problems:
%
% Tall objects after a tab stop may overlap the line abov, rather
% than forcing a greater separation between lines.
\ProvidesPackage{tabto}[2013/03/25 \space v 1.3 \space
Another tabbing mechanism]\relax
\newdimen\CurrentLineWidth
\let\TabPrevPos\z@
\newcommand\tabto[1]{%
\leavevmode
\begingroup
\def\@tempa{*}\def\@tempb{#1}%
\ifx\@tempa\@tempb % \tab*
\endgroup
\TTo@overlaptrue % ... set a flag and re-issue \tabto to get argument
\expandafter\tabto
\else
\ifinner % in a \hbox, so ignore
\else % unrestricted horizontal mode
\null% \predisplaysize will tell the position of this box (must be box)
\parfillskip\fill
\everydisplay{}\everymath{}%
\predisplaypenalty\@M \postdisplaypenalty\@M
$$% math display so we can test \predisplaysize
\lineskiplimit=-999pt % so we get pure \baselineskip
\abovedisplayskip=-\baselineskip \abovedisplayshortskip=-\baselineskip
\belowdisplayskip\z@skip \belowdisplayshortskip\z@skip
\halign{##\cr\noalign{%
% get the width of the line above
%\message{>>> Line \the\inputlineno\space -- \predisplaydirection\the\predisplaydirection, \predisplaysize\the\predisplaysize, \displayindent\the\displayindent, \leftskip\the\leftskip, \linewidth\the\linewidth. }%
\ifdim\predisplaysize=\maxdimen % mixed R and L; call the line full
\message{Mixed R and L, so line is full. }%
\CurrentLineWidth\linewidth
\else
\ifdim\predisplaysize=-\maxdimen % impossible, in vmode; call the line empty
\message{Not in paragraph, so line is empty. }%
\CurrentLineWidth\z@
\else
\ifnum\TTo@Direction<\z@
\CurrentLineWidth\linewidth \advance\CurrentLineWidth\predisplaysize
\else
\CurrentLineWidth\predisplaysize
\fi
% Correct the 2em offset
\advance\CurrentLineWidth -2em
\advance\CurrentLineWidth -\displayindent
\advance\CurrentLineWidth -\leftskip
\fi\fi
\ifdim\CurrentLineWidth<\z@ \CurrentLineWidth\z@\fi
% Enshrine the tab-to position; #1 might reference \CurrentLineWidth
\@tempdimb=#1\relax
\message{*** Tab to \the\@tempdimb, previous width is \the\CurrentLineWidth. ***}%
% Save width for possible return use
\xdef\TabPrevPos{\the\CurrentLineWidth}%
% Build the action to perform
\protected@xdef\TTo@action{%
\vrule\@width\z@\@depth\the\prevdepth
\ifdim\CurrentLineWidth>\@tempdimb
\ifTTo@overlap\else
\protect\newline \protect\null
\fi\fi
\protect\nobreak
\protect\hskip\the\@tempdimb\relax
}%
%\message{\string\TTo@action: \meaning \TTo@action. }%
% get back to the baseline, regardless of its depth.
\vskip-\prevdepth
\prevdepth-99\p@
\vskip\prevdepth
}}%
$$
% Don't count the display as lines in the paragraph
\count@\prevgraf \advance\count@-4 \prevgraf\count@
\TTo@action
%% \penalty\@m % to allow a penalized line break
\fi
\endgroup
\TTo@overlapfalse
\ignorespaces
\fi
}
% \tab -- to the next position
% \hskip so \tab\tab moves two positions
% Allow a (penalized but flexible) line-break right after the tab.
%
\newcommand\tab{\leavevmode\hskip2sp\tabto{\NextTabStop}%
\nobreak\hskip\z@\@plus 30\p@\penalty4000\hskip\z@\@plus-30\p@\relax}
% Expandable macro to select the next tab position from the list
\newcommand\NextTabStop{%
\expandafter \TTo@nexttabstop \TabStopList,\maxdimen,>%
}
\def\TTo@nexttabstop #1,{%
\ifdim#1<\CurrentLineWidth
\expandafter\TTo@nexttabstop
\else
\ifdim#1<0.9999\linewidth#1\else\z@\fi
\expandafter\strip@prefix
\fi
}
\def\TTo@foundtabstop#1>{}
\newcommand\TabPositions[1]{\def\TabStopList{\z@,#1}}
\newcommand\NumTabs[1]{%
\def\TabStopList{}%
\@tempdimb\linewidth
\divide\@tempdimb by#1\relax
\advance\@tempdimb 1sp % counteract rounding-down by \divide
\CurrentLineWidth\z@
\@whiledim\CurrentLineWidth<\linewidth\do {%
\edef\TabStopList{\TabStopList\the\CurrentLineWidth,}%
\advance\CurrentLineWidth\@tempdimb
}%
\edef\TabStopList{\TabStopList\linewidth}%
}
% default setting of tab positions:
\TabPositions{\parindent,.5\linewidth}
\newif\ifTTo@overlap \TTo@overlapfalse
\@ifundefined{predisplaydirection}{
\let\TTo@Direction\predisplaysize
\let\predisplaydirection\@undefined
}{
\let\TTo@Direction\predisplaydirection
}