diff options
Diffstat (limited to 'macros/luatex/generic')
-rw-r--r-- | macros/luatex/generic/luaaddplot/README.md | 34 | ||||
-rw-r--r-- | macros/luatex/generic/luaaddplot/luaaddplot.dtx | 300 | ||||
-rw-r--r-- | macros/luatex/generic/luaaddplot/luaaddplot.ins | 19 | ||||
-rw-r--r-- | macros/luatex/generic/luaaddplot/luaaddplot.pdf | bin | 0 -> 258501 bytes | |||
-rw-r--r-- | macros/luatex/generic/luatexko/ChangeLog | 7 | ||||
-rw-r--r-- | macros/luatex/generic/luatexko/README | 2 | ||||
-rw-r--r-- | macros/luatex/generic/luatexko/luatexko-doc.pdf | bin | 338346 -> 339172 bytes | |||
-rw-r--r-- | macros/luatex/generic/luatexko/luatexko-doc.tex | 2 | ||||
-rw-r--r-- | macros/luatex/generic/luatexko/luatexko-normalize.lua | 6 | ||||
-rw-r--r-- | macros/luatex/generic/luatexko/luatexko-uhc2utf8.lua | 6 | ||||
-rw-r--r-- | macros/luatex/generic/luatexko/luatexko.lua | 6 | ||||
-rw-r--r-- | macros/luatex/generic/luatexko/luatexko.sty | 6 |
12 files changed, 374 insertions, 14 deletions
diff --git a/macros/luatex/generic/luaaddplot/README.md b/macros/luatex/generic/luaaddplot/README.md new file mode 100644 index 0000000000..ce4f4448e3 --- /dev/null +++ b/macros/luatex/generic/luaaddplot/README.md @@ -0,0 +1,34 @@ +luaaddeplot +=========== + +Version +------- +1.0 + +Author +------ +Reinhard Kotucha <a href="mailto:Reinhard.Kotucha@gmx.de">Reinhard.Kotucha@gmx.de</a> + +License +------- +LPPL v1.3 or any later version. + +Description +----------- +luaaddplot is an extension to pgfplots which extends the `\addplot` +macro by a facility which allows modification of data files while they +are read. With luaaddplot it's not necessary anymore to pre-process +data files generated by measuring devices with external scripts. + +This package can be used with plain LuaTeX or LuaLaTeX. + +Installation +------------ +Copy + +`luaaddplot.tex` and `luaaddplot.lua` to `tex/generic/luaaddplot` + +and + +`luaaddplot.sty` to `tex/latex/luaaddplot`. + diff --git a/macros/luatex/generic/luaaddplot/luaaddplot.dtx b/macros/luatex/generic/luaaddplot/luaaddplot.dtx new file mode 100644 index 0000000000..7d3e4bf8c2 --- /dev/null +++ b/macros/luatex/generic/luaaddplot/luaaddplot.dtx @@ -0,0 +1,300 @@ +% \iffalse meta-comment +% +% $Id: luaaddplot.dtx 3 2022-03-19 23:12:51Z reinhard $ +% +%<*driver> +\documentclass[a4paper,11pt]{ltxdoc} +\MakeShortVerb{\|} + +\advance\textheight by 2\baselineskip +\usepackage[english]{babel} +\usepackage{tgpagella} +\usepackage[dvipsnames]{xcolor} +\usepackage{parskip} +\usepackage{siunitx} +\usepackage[colorlinks,bookmarksopen,bookmarksnumbered]{hyperref} +\hypersetup{linkcolor=BrickRed} + +\author{Reinhard Kotucha} +\title{\textsf{luaaddplot}} +\begin{document} +\maketitle +\vspace*{1cm} + +\begin{abstract} + \parindent=0pt \parskip=1ex + \noindent The \textsf{pgfplots} package supports plotting data from files. + If these files are generated by measuring devices they almost always + have to be pre-processed. + + This packge provides a macro |\luaaddplot| which extends the + functionality of |\addplot| by an optional argument containing + a $\lambda$- expression which is evaluated for each line of the data + file. + + The package requires Lua\TeX\ or Lua\LaTeX. +\end{abstract} +\vspace*{1cm} +\tableofcontents +\vspace*{\fill} + +\newpage + +\section{Introduction} +When plotting files generated by measuring devices the data files +often have to be pre-processed before they can be passed to \textsf{pgfplots}. +In most cases a header describing the device configuration must be +removed, column delimiters have to be changed, and units have to be +scaled (\si{\hertz} to \si{\mega\hertz}, \si{\volt} to +\si{\micro\volt}, etc\ldots). In some cases more complex operations +are required. + +\subsection{Usage} + +\verb| \luaaddplot|\oarg{options}| file "|% +$\langle$\textit{filename}$\rangle$|"|[|, |$\langle$\textit{$\lambda$-expression}$\rangle$]|;| + +Everything between \cs{luaaddplot} and the keyword |file| is passed to +\cs{addplot}, everything between |file| and the semicolon is +processed by Lua and valid Lua syntax is required here. You can +consider code between |file| and the terminating semicolon as +arguments of a Lua function with braces omitted. + +\subsection{Reading the data file} + +Data files generated by measuring devices usually have an ASCII +header describing the settings. These lines are often preceded by +comment characters but not always. In order to avoid pre-processing +with another tool, all lines which do not begin with a number are +ignored. + +Different devices use different column delimiters. Therefore tabs, +colons, semicolons, and commas are replaced by a space. With other +words, various datafile formats are converted to a format specified by +\textsc{Matlab}. + +\subsection{\texorpdfstring{$\lambda$}{lambda}-Expressions} + +A $\lambda$-expression is an anonymous function and looks like this: +\begin{verbatim} + function (a) + return a[1], a[2] + end +\end{verbatim} + +The formal parameter |a| (its name can be chosen arbitrarily) is +replaced by an ordered list of columns for each line in the data file. +The return values are the $x$ and $y$ values to be plotted and are +passed to \cs{addplot}. Always two values must be returned. Please +note that the index of the first column is 1 in Lua and not 0, as in +many other programming languages. + +In the example above the first and second column of the data file +will be plotted. This is the default if the $\lambda$-expression is +omitted. + +\newpage + +\section{Examples} + +\subsection{Scaling} + +The following is an excerpt of a data file generated by a spectrum analyzer. + +\begin{verbatim} +x-Unit;Hz; +y-Unit;dBm; +Preamplifier;OFF; +Transducer;OFF; +Values;501; +0;43.660163879394531; +6000000;-53.616184234619141; +12000000;-60.31707763671875; +18000000;-62.548038482666016; +54000000;-66.722061157226563; +\end{verbatim} + +Frequencies are in \si{\hertz} but for the plot we prefer +\si{\mega\hertz}. The solution is +\begin{verbatim} +\luaaddplot[blue] file "spectrum.data", function (col) + return col[1]/1e6, col2 + end; +\end{verbatim} + + +\subsection{Processing} + +The following is an excerpt of a data file generated by a vector +network analyzer. + +\begin{verbatim} +%% Date: 2021-02-25 11:36:04 +%% Data & Calibration Information: +%% Trc1:S11(Full One Port) +%%freq[Hz] re:Trc1_S11 im:Trc1_S11 +6.650000000000000E+008,3.684957681171731E-001,-9.205383204111828E-001, +6.652500000000000E+008,3.717039523633851E-001,-9.215835251874305E-001, +6.655000000000000E+008,3.687706454916999E-001,-9.207422307051146E-001, +6.657500000000000E+008,3.574212650433284E-001,-9.176705980253278E-001, +6.660000000000000E+008,3.453552411257967E-001,-9.254690887689956E-001, +\end{verbatim} + +The first column denotes the frequency in \si{\hertz}, the second and +third column denote the real and imaginary part of the impedance +$s_{11}$ respectively. + +Now we want to plot +\begin{displaymath} + 20 \log_{10} \sqrt{(\text{Re\,} s_{11})^2 + (\text{Im\,} s_{11})^2} +\end{displaymath} +with frequencies in \si{\mega\hertz}. + +The solution is +\begin{verbatim} +\luaaddplot[green] file "s11.data", + function (col) + return col[1]/1e6, 20*math.log10(math.sqrt(col[2]^2 + col[3]^2)) + end; +\end{verbatim} + + +\newpage +\section{Implementation} +\DocInput{luaaddplot.dtx} +\end{document} +%<*tex|sty|lua> +%</tex|sty|lua> + +%</driver> +% \fi +% \begin{macrocode} +%<tex>%% File 'luaaddplot.tex', generated from luaaddplot.dtx'. +%<sty>%% File 'luaaddplot.sty', generated from luaaddplot.dtx'. +%<lua>-- File 'luaaddplot.lua', generated from luaaddplot.dtx'. +%<lua>--[[ +%% +%% luaaddplot.dtx +%% Copyright 2022 Reinhard Kotucha <reinhard.kotucha@gmx.net> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Reinhard Kotucha. +%% +%% This work consists of the files luaaddplot.dtx and luaaddplot.ins +%% and the derived files luaaddplot.tex, luaaddplot.sty, and luaaddplot.lua. +%<lua>--]] +% \end{macrocode} +% \subsection{luaaddplot.tex} +% \begin{macrocode} +%<*tex> +\directlua{require('luaaddplot')} +\def\luaaddplot#1file#2;{ + \directlua{luaaddplot.opts('#1')luaaddplot.readfile(#2)}} +%</tex> +% \end{macrocode} +% \subsection{luaaddplot.sty} +% \begin{macrocode} +%<*sty> \ProvidesPackage{luaaddplot}[2022/03/18/ v1.0] +\input luaaddplot.tex +%</sty> +% \end{macrocode} +% \subsection{luaaddplot.lua} +% \begin{macrocode} +%<*lua> + +module('luaaddplot', package.seeall) + +% \end{macrocode} +% \DescribeMacro{readfile()} +% Read and pre-process file \verb|file| and apply +% $\lambda$-expression. If the second argument is \verb|nil| the +% first and second column is returned. +% \begin{macrocode} +function readfile (file, lambda) +% \end{macrocode} +% Check whether datafile exists. +% \begin{macrocode} + if not lfs.isfile(file) then + error('\nERROR: File "'..file..'" not found.') + end + + local data = io.open(file) + + for line in data:lines() do +% \end{macrocode} +% Remove all spaces at the beginning of a line. +% \begin{macrocode} + line = line:gsub('^%s+', '') +% \end{macrocode} +% Ignore all lines which don't begin with a number. All comments +% and empty lines in data files are ignored. +% \begin{macrocode} + if line:match('^%-?%.?[0-9]') then +% \end{macrocode} +% Replace possible non-space delimiters by spaces. This allows to +% process various datafile formats the same way as \textsc{Matlab} +% files without manual interaction. +% \begin{macrocode} + line = line:gsub('[\t:;,]', ' ') +% \end{macrocode} +% The result must be a table with two columns. If no $\lambda$ +% expression is provided, the first two colums of the data file are +% returned. With a $\lambda$ expression as second argument arbitrary +% columns can be selected from a data file and can be pre-processed in +% any way possible. +% \begin{macrocode} + local a, b + local cols = line:explode (' +') +% \end{macrocode} +% Convert strings to numbers. Because $\lambda$ expressions can +% access any column we convert all table entries from strings +% to numbers, if possible, instead of only the return values. +% Numbers are returned to \TeX\ as floating point numbers. +% \begin{macrocode} + for i, col in ipairs(cols) do + cols[i] = tonumber(cols[i]) + end + + if lambda then + a, b = lambda(cols) + if a and b then + tex.print(string.format('%g %g', a, b)) + end + else + tex.print(string.format('%g %g', cols[1], cols[2])) + end + end + end + tex.print('};') + data:close() +end +% \end{macrocode} +% \DescribeMacro{opts()} +% Pass optional arguments from \verb|\luaaddplot| to \verb|\addplot|. +% \begin{macrocode} + +function opts (s) + tex.print('\\addplot'..s..' table {') +end + +% </lua> +% \end{macrocode} + +%\endinput +% Local Variables: +% mode: LaTeX +% TeX-master: t +% TeX-engine: luatex +% indent-tabs-mode: nil +% coding: utf-8-unix +% End: +% vim:set tabstop=2 expandtab: diff --git a/macros/luatex/generic/luaaddplot/luaaddplot.ins b/macros/luatex/generic/luaaddplot/luaaddplot.ins new file mode 100644 index 0000000000..e6258a3a70 --- /dev/null +++ b/macros/luatex/generic/luaaddplot/luaaddplot.ins @@ -0,0 +1,19 @@ + +% $Id: luaaddplot.ins 2 2022-03-19 23:02:47Z reinhard $ + +\input docstrip + +\nopreamble +\askforoverwritefalse + +\usedir{tex/latex/luaaddplot} + + \generate{\file{luaaddplot.sty}{\from{luaaddplot.dtx}{sty}}} + +\usedir{tex/generic/luaaddplot} + + \generate{\file{luaaddplot.tex}{\from{luaaddplot.dtx}{tex}}} + \nopostamble + \generate{\file{luaaddplot.lua}{\from{luaaddplot.dtx}{lua}}} + +\endbatchfile diff --git a/macros/luatex/generic/luaaddplot/luaaddplot.pdf b/macros/luatex/generic/luaaddplot/luaaddplot.pdf Binary files differnew file mode 100644 index 0000000000..875fac1157 --- /dev/null +++ b/macros/luatex/generic/luaaddplot/luaaddplot.pdf diff --git a/macros/luatex/generic/luatexko/ChangeLog b/macros/luatex/generic/luatexko/ChangeLog index 62e73af1e4..208b56d08c 100644 --- a/macros/luatex/generic/luatexko/ChangeLog +++ b/macros/luatex/generic/luatexko/ChangeLog @@ -1,3 +1,10 @@ +2022-03-20 Dohyun Kim <nomos at ktug org> + + Version 3.4 + + * luatexko.sty: + - do not delay loading of konames-utf.sty + 2021-07-10 Dohyun Kim <nomos at ktug org> Version 3.3 diff --git a/macros/luatex/generic/luatexko/README b/macros/luatex/generic/luatexko/README index fd2b7fd95b..da8e77294c 100644 --- a/macros/luatex/generic/luatexko/README +++ b/macros/luatex/generic/luatexko/README @@ -1,4 +1,4 @@ -LuaTeX-ko Package version 3.3 (2021/07/10) +LuaTeX-ko Package version 3.4 (2022/03/20) =========================================== This is a Lua(La)TeX macro package that supports typesetting Korean diff --git a/macros/luatex/generic/luatexko/luatexko-doc.pdf b/macros/luatex/generic/luatexko/luatexko-doc.pdf Binary files differindex 033ac28c5b..7f2be3cd7b 100644 --- a/macros/luatex/generic/luatexko/luatexko-doc.pdf +++ b/macros/luatex/generic/luatexko/luatexko-doc.pdf diff --git a/macros/luatex/generic/luatexko/luatexko-doc.tex b/macros/luatex/generic/luatexko/luatexko-doc.tex index 8b32a6f49e..deb48a91bd 100644 --- a/macros/luatex/generic/luatexko/luatexko-doc.tex +++ b/macros/luatex/generic/luatexko/luatexko-doc.tex @@ -142,7 +142,7 @@ \author{Dohyun Kim \normalsize |<nomos at ktug org>| \and Soojin Nam \normalsize |<jsunam at gmail com>| \and \normalsize <\url{http://github.com/dohyunkim/luatexko}>} -\date{Version 3.3\quad 2021/07/10} +\date{Version 3.4\quad 2022/03/20} \maketitle \begin{quote} diff --git a/macros/luatex/generic/luatexko/luatexko-normalize.lua b/macros/luatex/generic/luatexko/luatexko-normalize.lua index 961d581c79..49c076915b 100644 --- a/macros/luatex/generic/luatexko/luatexko-normalize.lua +++ b/macros/luatex/generic/luatexko/luatexko-normalize.lua @@ -1,6 +1,6 @@ -- luatexko-normalize.lua -- --- Copyright (c) 2013-2021 Dohyun Kim <nomos at ktug org> +-- Copyright (c) 2013-2022 Dohyun Kim <nomos at ktug org> -- Soojin Nam <jsunam at gmail com> -- -- This work may be distributed and/or modified under the @@ -13,8 +13,8 @@ luatexbase.provides_module({ name = "luatexko-normalize", - version = "3.3", - date = "2021/07/10", + version = "3.4", + date = "2022/03/20", author = "Dohyun Kim, Soojin Nam", description = "Hangul normalization", license = "LPPL v1.3+", diff --git a/macros/luatex/generic/luatexko/luatexko-uhc2utf8.lua b/macros/luatex/generic/luatexko/luatexko-uhc2utf8.lua index 1a48a48693..59517fbcc7 100644 --- a/macros/luatex/generic/luatexko/luatexko-uhc2utf8.lua +++ b/macros/luatex/generic/luatexko/luatexko-uhc2utf8.lua @@ -1,6 +1,6 @@ -- luatexko-uhc2utf8.lua -- --- Copyright (c) 2013-2021 Dohyun Kim <nomos at ktug org> +-- Copyright (c) 2013-2022 Dohyun Kim <nomos at ktug org> -- Soojin Nam <jsunam at gmail com> -- -- This work may be distributed and/or modified under the @@ -13,8 +13,8 @@ luatexbase.provides_module({ name = "luatexko-uhc2utf8", - version = "3.3", - date = "2021/07/10", + version = "3.4", + date = "2022/03/20", author = "Dohyun Kim, Soojin Nam", description = "UHC (CP949) input encoding", license = "LPPL v1.3+", diff --git a/macros/luatex/generic/luatexko/luatexko.lua b/macros/luatex/generic/luatexko/luatexko.lua index 6b82a190f5..b46abe07a2 100644 --- a/macros/luatex/generic/luatexko/luatexko.lua +++ b/macros/luatex/generic/luatexko/luatexko.lua @@ -1,6 +1,6 @@ -- luatexko.lua -- --- Copyright (c) 2013-2021 Dohyun Kim <nomos at ktug org> +-- Copyright (c) 2013-2022 Dohyun Kim <nomos at ktug org> -- Soojin Nam <jsunam at gmail com> -- -- This work may be distributed and/or modified under the @@ -13,8 +13,8 @@ luatexbase.provides_module { name = 'luatexko', - date = '2021/07/10', - version = '3.3', + date = '2022/03/20', + version = '3.4', description = 'typesetting Korean with LuaTeX', author = 'Dohyun Kim, Soojin Nam', license = 'LPPL v1.3+', diff --git a/macros/luatex/generic/luatexko/luatexko.sty b/macros/luatex/generic/luatexko/luatexko.sty index 0cfb6da6a9..a6d4419d26 100644 --- a/macros/luatex/generic/luatexko/luatexko.sty +++ b/macros/luatex/generic/luatexko/luatexko.sty @@ -1,6 +1,6 @@ % luatexko.sty % -% Copyright (c) 2013-2021 Dohyun Kim <nomos at ktug org> +% Copyright (c) 2013-2022 Dohyun Kim <nomos at ktug org> % Soojin Nam <jsunam at gmail com> % % This work may be distributed and/or modified under the @@ -14,7 +14,7 @@ \ifdefined\luatexkohangulfontattr \endinput\fi \ifdefined\ProvidesPackage \NeedsTeXFormat{LaTeX2e}[2021/06/01] - \ProvidesPackage{luatexko}[2021/07/10 v3.3 typesetting Korean with LuaTeX] + \ProvidesPackage{luatexko}[2022/03/20 v3.4 typesetting Korean with LuaTeX] \RequirePackage{luatexbase} \RequirePackage{fontspec}[2020/02/03] \else @@ -967,12 +967,12 @@ \def\가{가}\def\이{이}\def\라{라}\def\으{으}\def\로{로}% \def\hellipsis{...}}}{} \@ifpackageloaded{pxrubrica}{\let\ruby\jruby}{} - \if@hangul \RequirePackage{konames-utf}\fi } % misc \RequirePackage{kolabels-utf} \protected\def\hellipsis{\char"2026\char"2026 } \if@hangul + \RequirePackage{konames-utf} \linespread{1.3888} \footnotesep=1.3888\footnotesep \skip\footins=\glueexpr\skip\footins/72*100\relax |