summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/lualatex/placeat/placeat.dtx228
1 files changed, 137 insertions, 91 deletions
diff --git a/Master/texmf-dist/source/lualatex/placeat/placeat.dtx b/Master/texmf-dist/source/lualatex/placeat/placeat.dtx
index 50bab39f7ed..bd3194dafe5 100644
--- a/Master/texmf-dist/source/lualatex/placeat/placeat.dtx
+++ b/Master/texmf-dist/source/lualatex/placeat/placeat.dtx
@@ -4,21 +4,21 @@
\iffalse
%</driver>
%<*readme>
-This is the README file of the placeat package. The package provides several commands to place content at an arbitrary position of the current page in any document. For orientation, a grid is drawn. Simple graphical elements like arrows and circles can be easily drawn and positioned.
+This is the README file of the placeat package. The package provides several commands to place content at an arbitrary position of the current page in any document. For orientation, a grid is drawn. Simple graphical elements like arrows and circles can easily be drawn and positioned.
To produce the package files, run lualatex on placeat.dtx, wich should result in the creation of the following files:
placeat.pdf (documentation)
placeat.sty (LaTeX user interface)
placeat.lua (Lua package code)
-You need an up-to-date TeX Live (2013) and compilation with LuaLaTeX to use this package. A full, updated MiKTeX should also work. (Not tested.)
+You need an up-to-date TeX Live (2017 at best) and compilation with LuaLaTeX to use this package. A full, updated MiKTeX should also work. (Not tested.)
For any comments or suggestions, contact me:
arno dot trautmann at gmx dot de
Hope you have fun with this package!
-This package is copyright © 2014 Arno L. Trautmann. It may be distributed and/or
+This package is copyright © 2017 Arno L. Trautmann. It may be distributed and/or
modified under the conditions of the LaTeX Project Public License, either version 1.3c
of this license or (at your option) any later version. This work has the LPPL mainten-
ance status ‘maintained’.
@@ -36,7 +36,7 @@ ance status ‘maintained’.
EXPERIMENTAL CODE
-This package is copyright © 2014 Arno L. Trautmann. It may be distributed and/or
+This package is copyright © 2017 Arno L. Trautmann. It may be distributed and/or
modified under the conditions of the LaTeX Project Public License, either version 1.3c
of this license or (at your option) any later version. This work has the LPPL mainten-
ance status ‘maintained’.
@@ -72,9 +72,10 @@ ance status ‘maintained’.
array,
babel,
booktabs,
+ fontspec, %% has to be in this order because of strange check in fixltl2e …
float,
- fontspec,
geometry,
+ graphicx,
hyperref,
microtype,
scrpage2,
@@ -97,11 +98,20 @@ ance status ‘maintained’.
\usepackage{placeat}
\placeatsetup{nogrid}
+\def\ALT{%
+ \bgroup%
+ \fontspec{Latin Modern Sans}%
+ A%
+ \kern-.37em \raisebox{.7ex}{\scalebox{0.25}{L}}%
+ \kern-.0em \raisebox{-0.98ex}{T}%
+ \egroup%
+}
+
\begin{document}
-\centerline{\fontsize{40}{55}\selectfont placeat}
+\centerline{\fontsize{40}{55}\selectfont place\ALT}
-\centerline{v0.1a}
-\centerline{\hspace*{2cm} Arno Trautmann}
+\centerline{v0.1d}
+\centerline{\hspace*{2cm} Arno L. Trautmann}
\centerline{\href{mailto:arno.trautmann@gmx.de}{arno.trautmann@gmx.de}}
\kern.5cm
@@ -112,12 +122,12 @@ The package \textsf{placeat} offers the command \verb|\placeat(2,5){}| which pla
\begin{figure}[b]
\small\noindent
\fbox{\parbox{.97\textwidth}{
-This package is copyright © 2014 Arno L. Trautmann. It may be distributed and/or
+This package is copyright © 2017 Arno L. Trautmann. It may be distributed and/or
modified under the conditions of the LaTeX Project Public License, either version 1.3c
of this license or (at your option) any later version. This work has the LPPL maintenance status ‘maintained’. Whoever notes the face in the title gets a cookie when we meet.}}
\end{figure}
-\textcolor{red}{\textls{ATTENTION}} This package is in a very preliminary version and released for testing.
+\textcolor{red}{\textls{ATTENTION}} This package is in a very preliminary version and released for testing only. Any feature might be subject to changes without notice.
\section*{Introduction}
This is the documentation of the package |placeat|. When you load the package, a grid is drawn on every page of your document to aid you at placing stuff where you want it to be. This mainly makes sense in presentations, but might be used in any document. The main macro of this package \verb|\placeat...{}| offers several ways to use it:
@@ -199,16 +209,11 @@ For floating environments, even if they don't float (that would be stupid, would
Here, the third, argument is optional and specifies the width of the minipage. If not given, it will default to 10cm, which should be wide enough to contain anything you ever want to set using \verb|placeat|.
\subsection{User Options}
-Some of this package's features can be adjusted. For this, you can either pass the options to the package at loading time:
-\begin{verbatim}
-\usepackage[final]{placeat}
-\end{verbatim}
-Or you use, at any time in the document, the command
+Some of this package's features can be adjusted at any time in the document with the command
\begin{verbatim}
\placeatsetup{}
\end{verbatim}
-which takes all of the package options and some more that make no sense at package loading time.
-\textcolor{red}{ATTENTION:} Actually, so far the package option interface does not work, but \verb|\placeatsetup| is fine.
+Some of the options only make sense when used in the preamble, others only have a result when used in the text. However, none should result in an error, so feel free to do whatever nonesens you want to.
\subsection{The Grid}
If the number of grid lines does not suit you (there are ten horizontally and vertically), you can increase or decrease the number by
@@ -269,10 +274,16 @@ placefilledrectangleat(x1,y1)(x2,y2) & draws a filled rectangle.
\end{tabu}
\end{table}
-Missing are eliptical shapes, maybe rounded corners for the rectangles and maybe some funny stuff.\footnote{Yes, I \emph{will} add a penis-shape macro, but that will not be documented explicitely.}
+You can change the linewidth and therefore the thickness of lines with the simple call
+\begin{verbatim}
+\placeatsetup{linewidth=5}
+\end{verbatim}
+Default is 1, I have no idea in which unit, but it is a very nice thickness, I think. You can change the thickness any time and as often as you want.
+
+Missing are eliptical shapes, maybe rounded corners for the rectangles and maybe some funny stuff.\footnote{Yes, I \emph{will} add a penis-shape macro, but that will not be documented explicitely.} The arrowheads need a lot of work, too, of course.
\subsection{Colored forms}
-Every command of the ones listed above takes an optional argument that allows the specification of a color. This is based on the \textsc{xcolor}, so all colors known by that package are possible:
+You need to load the \textsc{xcolor} package to use colors.\footnote{Why is it not required in the \textsc{placeat} package? Because you might want to specify package options and that may collide with the loading here. However, every sane document working with color requires the package by default.} Every command of the ones listed above takes an optional argument that allows the specification of a color. This is based on the \textsc{xcolor}, so all colors known by that package are possible:
\begin{verbatim}
\placecircleat[blue](5,5)
@@ -283,7 +294,6 @@ Every command of the ones listed above takes an optional argument that allows th
By now, it is not possible to specify an rgb code or similar. If you want a very special color that is not defined in the \textsc{xcolor} package, just define it by yourself. However, as shown above, it is possible to mix colors using the \verb|red!50!green| syntax, which is very flexible and should cover normal every day use.
-
\section{Example}
Now, here are two examples on how to use the package. The first one is a code example only, while the second one shows the effect directly on the page.
@@ -350,20 +360,23 @@ Testing. Try to use this code and tell me what you think about it.
Bug reporting. Tell me especially what is buggy. I'd like to keep the package rather small and simple, so some bugs might be called features, but we'll see.
-Suggestions. I'm open to extend the functionality. Just tell me what you want and I'll try to implement it as soon as possible. Which might be never. But also maybe the next day. Well, try it! ☺
+Suggestions. I'm open to extend the functionality. Just tell me what you want and I'll try to implement it as soon as possible. Which might be never. But also maybe the next day. Well, try it!~{\huge ☺}
+
+\section{Thanks}
+Of course I have to thank Paul Isambert again for the code for drawing to the pdf file. Also I want to thank Rembrandt Wolpert who was the first one to report bugs and feature requests.
\newpage
That's it for the documentation, have fun, and\vspace{2cm}
\placeat(5,7){\Huge\rotatebox{45}{Happy \TeX ing!}}[happy]
-\placecircleat[red](4,4.5){20}
-\placecircleat[green](9,4.5){20}
-\placecircleat[blue](4,7.5){20}
-\placecircleat[orange](9,7.5){20}
+\placecircleat[red](4,4.5)(.2)
+\placecircleat[green](9,4.5)(.2)
+\placecircleat[blue](4,7.5)(.2)
+\placecircleat[orange](9,7.5)(.2)
\begin{luacode}
for i = 1,20 do
- tex.print("\\placecircleat[blue](12,6){"..(2*i).."}")
+ tex.print("\\placecircleat[blue](12,6)("..(0.05*i)..")")
end
\end{luacode}
@@ -382,7 +395,7 @@ end
% The Lua file is not found by using a simple |dofile("placeat.lua")| call, but we have to use kpse's |find_file|.
% \begin{macrocode}
\ProvidesPackage{placeat}%
- [2014/04/18 v0.1a absolute content positioning]
+ [2017/08/19 v0.1d absolute content positioning]
\RequirePackage{luatexbase}
\RequirePackage{luacode}
\RequirePackage{atbegshi}
@@ -465,7 +478,7 @@ end
% \subsection{Placing of floats etc.}
% For floats and similar stuff, it might be necessary or useful to pack everything into a minipage. You can do this by yourself, but I thought it might be nice to specify a corresponding user interface. Using \verb|\placeminipageat| is the same as using \verb|\placeat{}{}{content}| where content is packed into a minipage. The first two argument of \verb|\placeminipageat| must be given in braces |{4}{5}| and determine the position of the content. The third argument is optional and specifies the width of the minipage; if not give, it is assumed to be 10cm, wide enough for mostly anything you ever will place at.
% \begin{macrocode}
-\NewDocumentCommand\placeminipageat{d()O{10cm}m}{
+\NewDocumentCommand\placeminipageat{r()O{10cm}m}{
\gdef\widthofplaceat{#2}
\placeat(#1)
{\begin{minipage}{\widthofplaceat}{#3}\end{minipage}}
@@ -494,6 +507,7 @@ end
% \begin{macrocode}
\let\ifdrawgrid\iftrue
\luaexec{
+ arrowheadlength = 5
drawgrid = false
nr = 0
dacoord = {}
@@ -503,14 +517,16 @@ end
gridlinewidth = 0.01
offsetx = 0
offsety = 0
-}
+}
% \end{macrocode}
% Now the code that does the actual work here. We use Heiko Oberdiek's package \textsf{atbegshi} with the very useful macros \verb|\AtBeginShipout| and \verb|\AtBeginShipoutUpperLeftForeground|. Using these, we are free from any context of where the code is written, it is always executed at the shipout and therefore absolute positioning is possible.
+%
+% I have to use a quite weird way of checking wether to draw the grid or not, using a number instead of defining a \verb|\ifdrawgrid|. That one was working at some time, but now it is not anymore. No idea why, some handling of the input parsing in the arguments must have changed. Anyways, this is working and not too ugly, so we'll stick with that one for now.
% \begin{macrocode}
\AtBeginDocument{
\AtBeginShipout{%
\AtBeginShipoutUpperLeftForeground{%
- \ifdrawgrid\drawgrid\fi
+ \ifnum\drawgridnum = 1 \drawgrid\fi
\luaexec{%
for i = 1,nr do
tex.print(dacoord[i].."{\\csname command"..(i).."\\endcsname}")
@@ -528,9 +544,11 @@ end
\luatexlatelua{
pdf_print("q")
linewidth(gridlinewidth)
+ local factorh = tex.pageheight/gridnry/65536
+ local factorw = tex.pagewidth/gridnrx/65536
for i = 1,math.max(gridnrx,gridnry) do
- h = i*tex.pageheight/gridnry/65536
- w = i*tex.pagewidth/gridnrx/65536
+ h = i*factorh
+ w = i*factorw
move(0,-h) line(tex.pagewidth,-h) stroke()
move(w,0) line(w,-tex.pageheight) stroke()
end
@@ -541,7 +559,7 @@ end
\normalfont\fontsize{8}{10}\selectfont
\luaexec{
for i=1,math.max(gridnrx+offsetx,gridnry+offsety) do
- hfac = tex.pageheight/gridnry/65536 %% another empirical factor
+ hfac = tex.pageheight/gridnry/65536
wfac = tex.pagewidth/gridnrx/65536*1.005 %% another empirical factor
h = (i-1)*hfac
w = (i-1)*wfac
@@ -561,34 +579,50 @@ end
%
% I try to provide a basic set of stuff that might be useful. The \TeX\ interface implementation might change, but for now it is done with xparse instead of a much more saner simple |\def|. We will see where this will head to. First, there is an arrow, whose head looks very bad. I don't know how to fix this yet. Then there are circle, square and rectangle.
% \begin{macrocode}
-\NewDocumentCommand\placelineat{ou{(}u{,}u{)(}u{,}u{)}}{
- \placeat{#3}{#4}{\ignorespaces\IfValueT{#1}{\color{#1}}%
- \luatexlatelua{placelineat(#3,-#4,#5,-#6)}
+\NewDocumentCommand\placelineat{or()r()}{
+ \placeat(#2){\ignorespaces\IfValueT{#1}{\color{#1}} % only to fix the color!
+ \luatexlatelua{placelineat(#2,#3)}
+ }
+}
+\NewDocumentCommand\placearrowat{or()r()}{
+ \placeat(#2){\ignorespaces\IfValueT{#1}{\color{#1}}%
+ \luatexlatelua{placearrowat(#2,#3)}
+ }
+}
+\NewDocumentCommand\placecircleat{or()D(){.3}}{
+ \placeat(#2){\ignorespaces\IfValueT{#1}{\color{#1}}%
+ \luatexlatelua{placecircleat(#3,1)}
}
}
-\NewDocumentCommand\placearrowat{ou{(}u{,}u{)(}u{,}u{)}}{
- \placeat{#3}{#4}{\ignorespaces\IfValueT{#1}{\color{#1}}%
- \luatexlatelua{placearrowat(#3,-#4,#5,-#6)}
+\NewDocumentCommand\placefilledcircleat{or()D(){.3}}{
+ \placeat(#2){\ignorespaces\IfValueT{#1}{\color{#1}}%
+ \luatexlatelua{placecircleat(#3,1,true)}
}
}
-\NewDocumentCommand\placecircleat{ou{(}u{,}u{)}G{3}}{
- \placeat{#3}{#4}{\ignorespaces\IfValueT{#1}{\color{#1}}%
- \luatexlatelua{placecircleat(#5)}
+\NewDocumentCommand\placesquareat{or()G{3}}{
+ \placeat(#2){\ignorespaces\IfValueT{#1}{\color{#1}}%
+ \luatexlatelua{placesquareat(#3)}
}
}
-\NewDocumentCommand\placesquareat{ou{(}u{,}u{)}G{3}}{
- \placeat{#3}{#4}{\ignorespaces\IfValueT{#1}{\color{#1}}%
- \luatexlatelua{placesquareat(#5)}
+\NewDocumentCommand\placecurveat{or()r()r()r()}{
+ \placeat(#2){\ignorespaces\IfValueT{#1}{\color{#1}}%
+ \luatexlatelua{placecurveat(#2,#3,#4,#5)}
}
}
-\NewDocumentCommand\placerectangleat{ou{(}u{,}u{)(}u{,}u{)}}{
- \placeat{#3}{#4}{\ignorespaces\IfValueT{#1}{\color{#1}}%
- \luatexlatelua{placerectangleat(#3,-#4,#5,-#6)}
+\NewDocumentCommand\placerectangleat{O{black}r()d()}{
+ \placeat(#2){\ignorespaces\color{#1}%
+ \luatexlatelua{placerectangleat(#2,#3)}
}
}
-\NewDocumentCommand\placefilledrectangleat{ou{(}u{,}u{)(}u{,}u{)}}{
- \placeat{#3}{#4}{\ignorespaces\IfValueT{#1}{\color{#1}}%
- \luatexlatelua{placefilledrectangleat(#3,-#4,#5,-#6)}
+\NewDocumentCommand\placefilledrectangleat{O{black}r()r()}{
+ \placeat(#2){\ignorespaces\color{#1}%
+ \luatexlatelua{placerectangleat(#2,#3,true)}
+ }
+}
+\NewDocumentCommand\placeroundedat{sO{black}r()D(){0.1}D<>{1.5}}{
+ \placeat(#3){\ignorespaces\color{#2}%
+ \IfBooleanTF{#1}{\luatexlatelua{placecircleat(#4,#5,true)}}%
+ {\luatexlatelua{placecircleat(#4,#5)}}
}
}
% \end{macrocode}
@@ -600,13 +634,15 @@ end
\ExplSyntaxOn
\keys_define:nn{placeat}{
alphanumgrid.code:n = \directlua{alphanumgrid = true},
- final.code:n = \luaexec{placeat_final = true} \let\ifdrawgrid\iffalse,
- drawgrid.code:n = \global\let\ifdrawgrid\iftrue,
+ arrowheadlength.code:n = \directlua{arrowheadlength=#1},
+ final.code:n = \luaexec{placeat_final = true} \gdef\drawgridnum{0},
+ drawgrid.code:n = \gdef\drawgridnum{1},
gridnumber.code:n = \directlua{gridnr = #1 gridnrx = gridnr~gridnry = gridnr},
gridnumberx.code:n = \directlua{gridnrx = #1},
gridnumbery.code:n = \directlua{gridnry = #1},
gridlinewidth.code:n = \directlua{gridlinewidth = #1},
- nogrid.code:n = \global\let\ifdrawgrid\iffalse,
+ linewidth.code:n = {\placeat(1,1){\luatexlatelua{linewidth(#1)}}}, %% FIXME: this is a very nasty hack to implement user's choice of linewidth!
+ nogrid.code:n = \gdef\drawgridnum{0},
numnumgrid.code:n = \directlua{alphanumgrid = false},
offsetx.code:n = \directlua{offsetx = #1},
offsety.code:n = \directlua{offsety = #1},
@@ -640,7 +676,7 @@ function move (p1,p2)
end
end
-function line (p1,p2)
+function line(p1,p2)
pdf_print(p1,p2,"l")
end
@@ -655,11 +691,15 @@ function curve(p11,p12,p21,p22,p31,p32)
p3[1], p3[2], "c")
end
-function linewidth (w)
+function linewidth(w)
pdf_print(w,"w")
end
-function stroke ()
+function fill()
+ pdf_print("f")
+end
+
+function stroke()
pdf_print("S")
end
@@ -677,7 +717,7 @@ function placelineat(x1,y1,x2,y2)
xfac = tex.pagewidth/gridnrx/65536 -- factors to convert given number to absolute coordinates
yfac = tex.pageheight/gridnry/65536 -- should both be global!
xar = (x2-x1)*xfac -- end point of the arrow
- yar = (y2-y1)*yfac --
+ yar = (y1-y2)*yfac --
move(0,0) -- start
line(xar,yar) -- draw main line
stroke()
@@ -687,7 +727,7 @@ function placearrowat(x1,y1,x2,y2)
xfac = tex.pagewidth/gridnrx/65536 -- factors to convert given number to absolute coordinates
yfac = tex.pageheight/gridnry/65536 -- should both be global!
xar = (x2-x1)*xfac -- end point of the arrow
- yar = (y2-y1)*yfac --
+ yar = (y1-y2)*yfac --
parx = xar/math.sqrt(xar^2+yar^2) -- direction of the arrow
pary = yar/math.sqrt(xar^2+yar^2) --
perpx = -pary -- perp of the arrow direction
@@ -695,36 +735,37 @@ function placearrowat(x1,y1,x2,y2)
move(0,0) -- start
line(xar,yar) -- draw main line
move(xar,yar)
- line(xar-5*parx+5*perpx,yar-5*pary+5*perpy) -- draw arrowhead
+ line(xar-arrowheadlength*parx+arrowheadlength*perpx,yar-arrowheadlength*pary+arrowheadlength*perpy) -- draw arrowhead
move(xar,yar)
- line(xar-5*parx-5*perpx,yar-5*pary-5*perpy)
+ line(xar-arrowheadlength*parx-arrowheadlength*perpx,yar-arrowheadlength*pary-arrowheadlength*perpy)
stroke()
end
-- better circle-approximation by using quarter circles, according to wikipedia article about Bézier curves
-function placecircleat(radius)
- local k = 0.55228
+-- k = 1 gives a circle, everything else something else …
+function placecircleat(r,k,filled)
local P0,P1,P2,P3
+ r = r * 59.5 -- next arbitrary scale factor; the circle has radius "1" in x-units
+ local rk = 0.55228*r*k
- P0 = {radius,0} P1 = {radius,radius*k}
- P2 = {radius*k,radius} P3 = {0,radius}
+ P0 = {r,0}
+ move (P0[1],P0[2])
- move (P0[1],P0[2]) curve (P1,P2,P3)
+ P1 = {r,rk} P2 = {rk,r} P3 = {0,r}
+ curve (P1,P2,P3)
- P0 = {-radius,0} P1 = {-radius,radius*k}
- P2 = {-radius*k,radius} P3 = {0,radius}
+ P1 = {-rk,r} P2 = {-r,rk} P3 = {-r,0}
+ curve (P1,P2,P3)
- move (P0[1],P0[2]) curve (P1,P2,P3)
+ P1 = {-r,-rk} P2 = {-rk,-r} P3 = {0,-r}
+ curve (P1,P2,P3)
- P0 = {-radius,0} P1 = {-radius,-radius*k}
- P2 = {-radius*k,-radius} P3 = {0,-radius}
+ P1 = {rk,-r} P2 = {r,-rk} P3 = {r,0}
+ curve (P1,P2,P3)
- move (P0[1],P0[2]) curve (P1,P2,P3)
-
- P0 = {radius,0} P1 = {radius,-radius*k}
- P2 = {radius*k,-radius} P3 = {0,-radius}
-
- move (P0[1],P0[2]) curve (P1,P2,P3)
+ if filled then
+ fill()
+ end
stroke()
end
@@ -737,30 +778,35 @@ function placesquareat(length)
stroke()
end
-function placerectangleat(x1,y1,x2,y2)
+function placecurveat(x1,y1,x2,y2,x3,y3,x4,y4) -- start point and three numbers. Start is only offset.
+ xfac = tex.pagewidth/gridnrx/65536 -- factors to convert given number to absolute coordinates
+ yfac = tex.pageheight/gridnry/65536 -- should both be global!
+ x2 = (x2-x1)*xfac
+ y2 = (y2-y1)*yfac
+ x3 = (x3-x1)*xfac
+ y3 = (y3-y1)*yfac
+ x4 = (x4-x1)*xfac
+ y4 = (y4-y1)*yfac
+ move(0,0) -- start
+ curve(x2,-y2,x3,-y3,x4,-y4) -- coordinates for Bezier curve
+ stroke()
+end
+
+function placerectangleat(x1,y1,x2,y2,filled)
xfac = tex.pagewidth/gridnrx/65536
yfac = tex.pageheight/gridnry/65536
x2 = (x2-x1)*xfac
- y2 = (y2-y1)*yfac
+ y2 = (y1-y2)*yfac
move(0,0)
line(x2,0)
line(x2,y2)
line(0,y2)
line(0,0)
+ if filled then
+ fill()
+ end
stroke()
end
-
-function placefilledrectangleat(x1,y1,x2,y2)
- xfac = tex.pagewidth/gridnrx/65536
- yfac = tex.pageheight/gridnry/65536/1.0035 -- well, yes. Another random factor. lalala
- x2 = (x2-x1)*xfac
- y2 = (y2-y1)*yfac
- linewidth(y2)
- move(0,y2/2)
- line(x2,y2/2)
- stroke()
- linewidth(1)
-end
% \end{macrocode}
% \Finale
% \endinput