[latex3-commits] [git/LaTeX3-latex3-latex2e] develop: Gh168 (#916) (541f1c65)

GitHub noreply at github.com
Fri Sep 16 18:49:34 CEST 2022


Repository : https://github.com/latex3/latex2e
On branch  : develop
Link       : https://github.com/latex3/latex2e/commit/541f1c65e1da71f9ed1d753bdb30fa04adb2c122

>---------------------------------------------------------------

commit 541f1c65e1da71f9ed1d753bdb30fa04adb2c122
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Fri Sep 16 18:49:34 2022 +0200

    Gh168 (#916)
    
    * checking code for #168
    
    * add new entry
    
    * only warn if the outer minipage actually contains footnotes


>---------------------------------------------------------------

541f1c65e1da71f9ed1d753bdb30fa04adb2c122
 base/changes.txt               |  5 +++
 base/doc/ltnews36.tex          | 22 +++++++++++++
 base/ltboxes.dtx               | 34 +++++++++++++++++++-
 base/testfiles/github-0168.lvt | 64 ++++++++++++++++++++++++++++++++++++++
 base/testfiles/github-0168.tlg | 70 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 194 insertions(+), 1 deletion(-)

diff --git a/base/changes.txt b/base/changes.txt
index e595470d..c9b9b1c2 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,11 @@ completeness or accuracy and it contains some references to files that
 are not part of the distribution.
 ================================================================================
 
+2022-09-07  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
+
+	* ltboxes.dtx (section{\LaTeX\ Box commands}):
+	Check for nested minipages and warn if the outer one contains footnotes (gh/168)
+
 2022-09-03  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
 
 	* ltmath.dtx (subsubsection{The UNSORTED Rest}):
diff --git a/base/doc/ltnews36.tex b/base/doc/ltnews36.tex
index 842c28f7..cf571797 100644
--- a/base/doc/ltnews36.tex
+++ b/base/doc/ltnews36.tex
@@ -242,6 +242,19 @@ font instead.
 \githubissue{879}
 
 
+\subsection{Detect nested \texttt{minipage} environments}
+
+Nesting of \texttt{minipage} environments is only partially supported
+in \LaTeX{} and can lead to incorrect output, such as overfull boxes
+or footnotes appearing in the wrong place;
+see~\cite[p.~106]{36:Lamport}. However, until now there was no warning
+if that happpened.  This has been changed and the environment now
+warns if you nest it in another \texttt{minipage} environment that
+already contains footnotes.
+%
+\githubissue{168}
+
+
 
 \subsection{\LuaTeX\ callback efficiency improvement}
 
@@ -366,6 +379,15 @@ tall, in which case aligning is pointless anyway).
 %  \emph{\LaTeXe{} news 33}.\\
 %  \url{https://latex-project.org/news/latex2e-news/ltnews33.pdf}
 
+
+\bibitem{36:Lamport}
+Leslie Lamport.
+\newblock {\LaTeX}: {A} Document Preparation System: User's Guide and Reference
+  Manual.
+\newblock \mbox{Addison}-Wesley, Reading, MA, USA, 2nd edition, 1994.
+\newblock ISBN 0-201-52983-1.
+\newblock Reprinted with corrections in 1996.
+
 \bibitem{36:ltnews32} \LaTeX{} Project Team:
   \emph{\LaTeXe{} news 32}.\\
   \url{https://latex-project.org/news/latex2e-news/ltnews32.pdf}
diff --git a/base/ltboxes.dtx b/base/ltboxes.dtx
index 43db541b..b82f5bdb 100644
--- a/base/ltboxes.dtx
+++ b/base/ltboxes.dtx
@@ -33,7 +33,7 @@
 %<*driver>
 % \fi
 \ProvidesFile{ltboxes.dtx}
-             [2022/01/31 v1.4c LaTeX Kernel (Box Commands)]
+             [2022/09/07 v1.4d LaTeX Kernel (Box Commands)]
 % \iffalse
 \documentclass{ltxdoc}
 \GetFileInfo{ltboxes.dtx}
@@ -1004,6 +1004,16 @@
 %    \end{macrocode}
 % \end{macro}
 %
+%  \begin{macro}{\if at in@minipage at env}
+%    
+% \changes{v1.4d}{2022/09/07}
+%         {Check for nested minipages and warn (gh/168)}
+%    \begin{macrocode}
+\newif\if at in@minipage at env
+%    \end{macrocode}
+%  \end{macro}
+%
+%
 % \begin{macro}{\minipage}
 % \changes{v0.1a}{1993/12/03}
 %         {Redefined to support extra optional arguments}
@@ -1060,6 +1070,28 @@
     \color at begingroup
       \hsize\@tempdima
       \textwidth\hsize \columnwidth\hsize
+%    \end{macrocode}
+%    We check for nested minipages inside the box so that there is
+%    always a group resetting the switch even if the code does not use
+%    \cs{begin} to start the minipage.
+% \changes{v1.4d}{2022/09/07}
+%         {Check for nested minipages and warn (gh/168)}
+%    \begin{macrocode}
+      \if at in@minipage at env
+%    \end{macrocode}
+%    We only issue a warning if the outer minipage contained footnotes
+%    because that is the problematical case.
+%    \begin{macrocode}
+        \ifvoid\@mpfootins\else
+          \@latex at warning{Nested minipage:
+            footnotes may be misplaced}%
+        \fi
+      \else
+        \@in at minipage@envtrue
+      \fi
+%    \end{macrocode}
+%
+%    \begin{macrocode}
       \@parboxrestore
       \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c at mpfootnote\z@
       \let\@footnotetext\@mpfootnotetext
diff --git a/base/testfiles/github-0168.lvt b/base/testfiles/github-0168.lvt
new file mode 100644
index 00000000..72da4dae
--- /dev/null
+++ b/base/testfiles/github-0168.lvt
@@ -0,0 +1,64 @@
+\documentclass[12pt]{article}
+
+\input{test2e}
+
+
+\begin{document}
+
+\START
+
+\section{nested}
+
+\begin{minipage}{6cm}
+  some text\footnote{footnote A}
+
+  \hspace*{3cm}%
+  \begin{minipage}{3cm}
+    nested
+  \end{minipage}
+  
+  some text \footnote{footnote B}
+\end{minipage}
+
+
+\vspace*{2cm}
+
+
+\begin{minipage}{6cm}
+  some text\footnote{footnote A}
+
+  \parbox{3cm}{nested}
+ 
+  some text \footnote{footnote B}
+\end{minipage}
+
+
+\vspace*{2cm}
+
+
+\fbox{\parbox{8cm}{nested
+\begin{minipage}{6cm}
+  some text\footnote{footnote A}
+
+  some text \footnote{footnote B}
+\end{minipage}}}
+
+
+\section{nested but no warn}
+
+\begin{minipage}{6cm}
+  some text
+
+  \hspace*{3cm}%
+  \begin{minipage}{3cm}
+    nested
+  \end{minipage}
+  
+  some text \footnote{footnote C}
+\end{minipage}
+
+
+
+\newpage
+\OMIT
+\end{document}
diff --git a/base/testfiles/github-0168.tlg b/base/testfiles/github-0168.tlg
new file mode 100644
index 00000000..62eb91e0
--- /dev/null
+++ b/base/testfiles/github-0168.tlg
@@ -0,0 +1,70 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+LaTeX Font Info:    External font `cmex10' loaded for size
+(Font)              <12> on input line ....
+LaTeX Font Info:    External font `cmex10' loaded for size
+(Font)              <8> on input line ....
+LaTeX Font Info:    External font `cmex10' loaded for size
+(Font)              <6> on input line ....
+LaTeX Font Info:    External font `cmex10' loaded for size
+(Font)              <7> on input line ....
+LaTeX Font Info:    External font `cmex10' loaded for size
+(Font)              <5> on input line ....
+LaTeX Warning: Nested minipage: footnotes may be misplaced on input line ...
+Overfull \hbox (85.35826pt too wide) in paragraph at lines 15--19
+[]| $[]$ 
+\hbox(18.56668+12.56667)x170.71652
+.\hbox(0.0+0.0)x0.0
+.\rule(*+*)x0.0
+.\penalty 10000
+.\glue 85.35826
+.\glue 0.0
+.\mathon
+.\vbox(18.56668+12.56667)x170.71652
+..\hbox(8.33331+0.0)x85.35826, glue set 52.65443fil
+...\hbox(0.0+0.0)x0.0
+...\OT1/cmr/m/n/12 n
+...\OT1/cmr/m/n/12 e
+...\OT1/cmr/m/n/12 s
+...\OT1/cmr/m/n/12 t
+...\OT1/cmr/m/n/12 e
+...\OT1/cmr/m/n/12 d
+...\penalty 10000
+...\glue(\parfillskip) 0.0 plus 1.0fil
+...\glue(\rightskip) 0.0
+..\glue 10.8 plus 4.0 minus 2.0
+..\kern -3.0
+..\rule(0.4+0.0)x34.14278
+..\kern 2.6
+..\hbox(8.4+3.60004)x170.71652, glue set 105.77191fil
+...\hbox(6.6428+0.0)x18.00005, glue set 13.27779fil
+....\glue 0.0 plus 1.0fil minus 1.0fil
+....\hbox(6.6428+0.0)x4.72226
+.....\mathon
+.....\hbox(3.01389+0.0)x4.72226, shifted -3.62892
+......\OT1/cmr/m/it/7 a
+.....\mathoff
+...\hbox(8.4+0.0)x0.0
+....\rule(8.4+0.0)x0.0
+...\OT1/cmr/m/n/10 f
+...\OT1/cmr/m/n/10 o
+...\kern0.27779
+...\OT1/cmr/m/n/10 o
+...\OT1/cmr/m/n/10 t
+...\OT1/cmr/m/n/10 n
+...\OT1/cmr/m/n/10 o
+...\OT1/cmr/m/n/10 t
+...\OT1/cmr/m/n/10 e
+...\glue 3.33333 plus 1.66666 minus 1.11111
+...\OT1/cmr/m/n/10 A
+...\penalty 10000
+...\rule(0.0+3.60004)x0.0
+...\penalty 10000
+...\glue(\parfillskip) 0.0 plus 1.0fil
+...\glue(\rightskip) 0.0
+.\mathoff
+.\penalty 10000
+.\glue(\parfillskip) 0.0 plus 1.0fil
+.\glue(\rightskip) 0.0
+[1
+]





More information about the latex3-commits mailing list.