Browse Source

use grabbox for Rectangle

master
Jonathan Spratte 2 years ago
parent
commit
5b9a735c59
3 changed files with 13 additions and 21 deletions
  1. BIN
      Doc/doc_DSALaTeX.pdf
  2. 4
    0
      Doc/doc_DSALaTeX.tex
  3. 9
    21
      Doc/preamble/macros.tex

BIN
Doc/doc_DSALaTeX.pdf View File


+ 4
- 0
Doc/doc_DSALaTeX.tex View File

@@ -12,6 +12,10 @@
12 12
 \usepackage[style=draft]{biblatex}
13 13
 \addbibresource{doc_DSALaTeX.bib}
14 14
 
15
+% requires an up to date TeX Live, alternatively it is hosted here:
16
+% https://gitlass.de/jonathan/grabbox
17
+\usepackage{grabbox}
18
+
15 19
 \colorlet{alias}{blue!20!gray}
16 20
 
17 21
 \usepackage{DSALaTeX}

+ 9
- 21
Doc/preamble/macros.tex View File

@@ -93,6 +93,7 @@
93 93
 \newlength\Rectangle@length
94 94
 \newenvironment*{Rectangle}{}%>>>
95 95
   {%>>>
96
+    \ifhmode\unskip\fi
96 97
     \egroup
97 98
     \expandafter\Rectangle@Parse@Arg\expandafter{\Rectangle@Arg}%
98 99
   }%<<<
@@ -100,35 +101,24 @@
100 101
 \renewcommand*\Rectangle[1][]%>>>
101 102
   {%
102 103
     \begingroup
103
-    \def\Rectangle@Arg{#1}%
104 104
     \begingroup
105 105
     \def\Rectangle@TestString{Rectangle}
106 106
     \ifx\@currenvir\Rectangle@TestString
107 107
       % used as environment
108 108
       \endgroup
109
-      \expandafter\Rectangle@Environment
109
+      \def\Rectangle@Arg{#1}%
110
+      \expandafter\@firstoftwo
110 111
     \else
111 112
       % used as command
112 113
       \endgroup
113
-      \expandafter\Rectangle@Command
114
+      \expandafter\@secondoftwo
114 115
     \fi
116
+    \Rectangle@Environment
117
+    {\Rectangle@Command{#1}}%
115 118
   }%<<<
116
-\newcommand*\Rectangle@Command%>>>
117
-  {%
118
-    \begingroup
119
-    \afterassignment\Rectangle@Command@grab
120
-    \let\future
121
-  }%<<<
122
-\newcommand*\Rectangle@Command@grab%>>>
119
+\newcommand*\Rectangle@Command[1]%>>>
123 120
   {%
124
-    \endgroup
125
-    \setbox\Rectangle@box\hbox\bgroup
126
-    \aftergroup\Rectangle@Command@shipout
127
-    \ignorespaces
128
-  }%<<<
129
-\newcommand*\Rectangle@Command@shipout%>>>
130
-  {%
131
-    \expandafter\Rectangle@Parse@Arg\expandafter{\Rectangle@Arg}%
121
+    \grabbox\Rectangle@box\hbox{\Rectangle@Parse@Arg{#1}}%
132 122
   }%<<<
133 123
 \newcommand*\Rectangle@Environment%>>>
134 124
   {%
@@ -137,8 +127,6 @@
137 127
   }%<<<
138 128
 \newcommand*\Rectangle@Parse@Arg[1]%>>>
139 129
   {%
140
-    % remove trailing space after the contents of \Rectangle@box
141
-    \setbox\Rectangle@box\hbox{\unhbox\Rectangle@box\ifhmode\unskip\fi}%
142 130
     \if\relax\detokenize{#1}\relax
143 131
       \Rectangle@length\linewidth
144 132
     \else
@@ -148,7 +136,7 @@
148 136
           \Rectangle@length=\dimexpr\wd\Rectangle@box/#1\relax
149 137
           \ifdim\Rectangle@length>\linewidth
150 138
             \GenericWarning{}
151
-              {Warning: Rectangle paragraph's width bigger linewidth}%
139
+              {Warning: Rectangle paragraph's width bigger than linewidth}%
152 140
           \fi
153 141
         }%
154 142
     \fi

Loading…
Cancel
Save