diff options
author | Karl Berry <karl@freefriends.org> | 2011-02-22 23:51:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-02-22 23:51:25 +0000 |
commit | 2d9886476226f1af32a002690af6619e4676e948 (patch) | |
tree | 73f90c355292bc182fdbd8ae981ac41228bef0e2 /Master/texmf-dist | |
parent | 146759c9521ba1de269f5248b2f5fd09fd3bc003 (diff) |
drv 0.97 (22feb11)
git-svn-id: svn://tug.org/texlive/trunk@21499 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/metapost/drv/README | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/drv/doc/drv-guide.mp | 96 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/drv/doc/drv-guide.tex | 154 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/drv/doc/drv.mp | 250 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/drv/drv-guide.pdf | bin | 215341 -> 222384 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/metapost/drv/sample/drv.mp | 250 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/drv/template/drv.mp | 250 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/drv/template/template.mp | 3 | ||||
-rw-r--r-- | Master/texmf-dist/metapost/drv/drv.mp | 250 |
9 files changed, 817 insertions, 438 deletions
diff --git a/Master/texmf-dist/doc/metapost/drv/README b/Master/texmf-dist/doc/metapost/drv/README index 9052621445e..72248d2b54d 100644 --- a/Master/texmf-dist/doc/metapost/drv/README +++ b/Master/texmf-dist/doc/metapost/drv/README @@ -1,5 +1,5 @@ drv - derivation trees with MetaPost -version 0.96 +version 0.97 Licence lppl diff --git a/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.mp b/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.mp index 08f549c5533..e2bf1ba9833 100644 --- a/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.mp +++ b/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.mp @@ -63,8 +63,8 @@ verbatimtex%&latex %\usepackage{fourier} % Utopia & Fourier math %\usepackage[utopia]{mathdesign} % Utopia & Math Design math -\newcommand{\limp}{\thinspace{\multimapinv}\thinspace} -\newcommand{\rimp}{\thinspace{\multimap}\thinspace} +\newcommand{\limp}{\multimapinv} +\newcommand{\rimp}{\multimap} \begin{document} etex; @@ -1234,36 +1234,48 @@ endfig; drv_font_size "\large"; beginfig(470) % components -DCL 6 () ("", "", "", "", _, _, 0) "0"; -DCL 7 (6) ("(1)", "(2)", "(3)", "(4)", _, _, 1) "A", "B"; +DCL 5 () ("", "", "", "", _, _, 0) "A"; +DCL 6 (5) ("(1)", "(2)", "(3)", "(4)", _, _, 1) "B", "C"; +DCL 7 (MVD 6 (2, "(5)", "(6)", _, 6)) ("", "", "", "", _, _, 1) "D"; drv_freeze; % usually called by drv_tree -draw jdg[6]; % judgment 0 -draw sbj[7][0] withcolor (0, 0, 1); % sub-judgment A -draw sbj[7][1] withcolor (0, 1, 0); % sub-judgment B -draw l_ilb[7] withcolor (0, 1, 1); % left inference label (1) -draw r_ilb[7] withcolor (1, 0, 0); % right inference label (2) -draw l_dlb[7] withcolor (1, 0, 1); % left delimiter label (3) -draw r_dlb[7] withcolor (1, 1, 0); % right delimiter label (4) -draw l_dlm[7]; % left delimiter -draw iln[7]; % inference line -draw r_dlm[7]; % right delimiter +draw jdg[5]; % judgment A +draw sbj[6][0] withcolor (3, 0, 0)/3; % sub-judgment B +draw sbj[6][1] withcolor (2, 0, 0)/3; % sub-judgment C +draw iln[6] withcolor (0, 4, 0)/4; % inference line +draw l_ilb[6] withcolor (0, 3, 0)/4; % left inference label (1) +draw r_ilb[6] withcolor (0, 2, 0)/4; % right inference label (2) +draw l_dlm[6] withcolor (0, 0, 3)/3; % left delimiter +draw l_dlb[6] withcolor (0, 0, 2)/3; % left delimiter label (3) +draw r_dlm[6] withcolor (3, 0, 3)/3; % right delimiter +draw r_dlb[6] withcolor (2, 0, 2)/3; % right delimiter label (4) +draw phm[6] withcolor (0, 3, 3)/4; % phantom steps path +draw l_plb[6] withcolor (0, 2, 2)/4; % left phantom steps label (5) +draw r_plb[6] withcolor (0, 1, 1)/4; % right phantom steps label (6) +draw jdg[7]; % judgment D +draw iln[7]; % inference line endfig; beginfig(471) % central points -DCL 6 () ("", "", "", "", _, _, 0) "0"; -DCL 7 (6) ("(1)", "(2)", "(3)", "(4)", _, _, 1) "A", "B"; +DCL 5 () ("", "", "", "", _, _, 0) "A"; +DCL 6 (5) ("(1)", "(2)", "(3)", "(4)", _, _, 1) "B", "C"; +DCL 7 (MVD 6 (2, "(5)", "(6)", _, 6)) ("", "", "", "", _, _, 1) "D"; pickup pencircle scaled 2.5; -draw drv_tree withcolor .75(1, 1, 1); -draw jdg[6].c; % judgment 0 -draw sbj[7][0].c withcolor (0, 0, 1); % sub-judgment A -draw sbj[7][1].c withcolor (0, 1, 0); % sub-judgment B -draw l_ilb[7].c withcolor (0, 1, 1); % left inference label (1) -draw r_ilb[7].c withcolor (1, 0, 0); % right inference label (2) -draw l_dlb[7].c withcolor (1, 0, 1); % left delimiter label (3) -draw r_dlb[7].c withcolor (1, 1, 0); % right delimiter label (4) -draw l_dlm[7].c; % left delimiter -draw iln[7].c; % inference line -draw r_dlm[7].c; % right delimiter +draw drv_tree withcolor (3, 3, 3)/4; +draw jdg[5].c; % judgment A +draw sbj[6][0].c withcolor (3, 0, 0)/3; % sub-judgment B +draw sbj[6][1].c withcolor (2, 0, 0)/3; % sub-judgment C +draw iln[6].c withcolor (0, 4, 0)/4; % inference line +draw l_ilb[6].c withcolor (0, 3, 0)/4; % left inference label (1) +draw r_ilb[6].c withcolor (0, 2, 0)/4; % right inference label (2) +draw l_dlm[6].c withcolor (0, 0, 3)/3; % left delimiter +draw l_dlb[6].c withcolor (0, 0, 2)/3; % left delimiter label (3) +draw r_dlm[6].c withcolor (3, 0, 3)/3; % right delimiter +draw r_dlb[6].c withcolor (2, 0, 2)/3; % right delimiter label (4) +draw phm[6].c withcolor (0, 3, 3)/4; % phantom steps path +draw l_plb[6].c withcolor (0, 2, 2)/4; % left phantom steps label (5) +draw r_plb[6].c withcolor (0, 1, 1)/4; % right phantom steps label (6) +draw jdg[7].c; % judgment D +draw iln[7].c; % inference line endfig; drv_font_size "\normalsize"; @@ -1304,7 +1316,7 @@ endfor box_init n_hg(mth_tex[1]"\texttt{num\_hg}"); box_init d_dp(mth_tex[1]"\texttt{den\_dp}"); -drv_font_size "\fontsize{95}{0}"; +drv_font_size "\fontsize{100}{0}"; beginfig(480) dcl 0 () ("", 0) "\gamma"; @@ -1373,22 +1385,22 @@ drv_font_size "\normalsize"; beginfig(490) jgm 4 "A", "\vdash", "A"; -jgm 5 "B", "\vdash", "B"; -jgm 6 "A", ",", "A", "\multimap", "B", "\vdash", "B"; -jgm 7 "A", "\multimap", "B", "\vdash", "A", "\multimap", "B"; +jgm 5 "B", "_2", "\vdash", "B", "_3"; +jgm 6 "A", ",", "A", "\multimap", "B", "_1", "\vdash", "B", "_4"; +jgm 7 "A", "\multimap", "B", "_0", "\vdash", "A", "\multimap", "B", "_5"; nfr 4 () ("1", _); nfr 5 () ("1", _); nfr 6 (4, 5) ("\multimap_{L}", _); nfr 7 (6) ("\multimap_{R}", _); -drv_freeze; -draw (sbj[7][2].c shifted (0, -num_hg) .. - sbj[7][2].c {up} .. - sbj[6][4].c .. - sbj[5][0].c .. tension 1.05 .. - sbj[5][2].c .. - sbj[6][6].c .. - sbj[7][6].c {down} .. - sbj[7][6].c shifted (0, -num_hg)) +drv_freeze; % B +draw (sbj[7][2].c shifted (0, -num_hg) .. % 0 + sbj[7][2].c {up} .. % 0 + sbj[6][4].c .. % 1 + sbj[5][0].c .. tension 1.2 .. % 2 + sbj[5][3].c .. % 3 + sbj[6][7].c .. % 4 + sbj[7][7].c {down} .. % 5 + sbj[7][7].c shifted (0, -num_hg)) % 5 drv_styled 2 withcolor (1, 0, 0); draw drv_tree; endfig; @@ -1742,6 +1754,10 @@ drv_radial_mode off; % example - triple unit % +drv_verbatimtex + "\renewcommand{\limp}{\thinspace{\multimapinv}\thinspace}"& + "\renewcommand{\rimp}{\thinspace{\multimap}\thinspace}"; + string id, Llimp, Rlimp, Lrimp, Rrimp; id:="\text{id}"; Llimp:="\overset{\multimapinv}{\eta}"; diff --git a/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.tex b/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.tex index 4c8ea3606c7..e90bc73ac5c 100644 --- a/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.tex +++ b/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.tex @@ -1,9 +1,13 @@ +%\enlargethispage +%\pagebreak + % Any piece of code related to font selection in the following preamble % (document class, font package, font selection commands ...) should be % reported in `drv-guide.mp'. \documentclass[twoside,11pt]{article} \usepackage[T1]{fontenc} +\usepackage{microtype} \usepackage{amsmath} \usepackage{amssymb} \usepackage{stmaryrd} @@ -88,9 +92,9 @@ derivation trees with \MP% \thanks{Feel free to improve! (E.g., by correcting the poor English.) Last update: \today.}}} \author{Laurent \textsc{M\'ehats}\\ -{\small\href{mailto:laurent.mehats@gmail.com?subject=[drv 0.96]} +{\small\href{mailto:laurent.mehats@gmail.com?subject=[drv 0.97]} {\texttt{laurent.mehats@gmail.com}}}} -\date{documented version: 0.96} +\date{documented version: 0.97} \pagestyle{myheadings} \renewcommand{\sectionmark}[1]{% @@ -965,7 +969,6 @@ relatively to its premises.\\[1ex] \drv{drv-guide.321}& \end{array} \end{gather*} -\enlargethispage{.25\baselineskip}% Setting a default position for delimiter labels (thus for delimiters) and for phantom steps labels may be useful in conjunction with declaration macros taking optional label arguments (see~\S~\ref{sec-labels}). @@ -975,7 +978,6 @@ taking optional label arguments (see~\S~\ref{sec-labels}). \subsection{\texttt{drv\_roots\_position}\label{sec-roots-position}} % % -%\begin{multicols}{2} \texttt{drv\_roots\_position \param{id}}\\ \begin{tabular}{ll} \param{id}& position identifier ({\tt t} or {\tt b})\\ @@ -1033,7 +1035,7 @@ Notice that \texttt{drv\_axis\_reference} is irrelevant if you don't use the \texttt{"\tbs{}langle"}& $\langle$\\ etc. \end{tabular} -\end{tabular}\\[1ex] +\end{tabular}\clearpage\noindent%\\[1ex] \texttt{drv\_right\_delimiter \param{str}}\\ \begin{tabular}{ll} \param{str}& right delimiter math-mode \LaTeX\ code\\ @@ -1101,7 +1103,7 @@ typeset as& \subsection{\texttt{drv\_fraction\_mode}\label{sec-fraction-mode}} % % -\nopagebreak\parbox{\textwidth}{\texttt{drv} typesets derivation trees in +\texttt{drv} typesets derivation trees in such a way that: the distance from the axis of an inference line to the math axis of a judgment above it is always the same (\texttt{num\_hg}, see~\S~\ref{sec-components}); the distance from the axis of an inference line @@ -1112,7 +1114,7 @@ ignored (the depth of root judgments is always ignored); if roots are at top then the depth of leaf judgments below which there is no inference line is ignored (the height of root judgments is always ignored). This mode may cause overlaps when used in conjunction with -interlacing junction-styles (\texttt{0} and \texttt{1}).}\\[1ex] +interlacing junction-styles (\texttt{0} and \texttt{1}).\\[1ex] \texttt{drv\_fraction\_mode \param{id}}\\ \begin{tabular}{ll} \param{id}& status identifier ({\tt on} or {\tt off})\\ @@ -1157,6 +1159,39 @@ see~\S~\ref{sec-components}) while blue numbers (resp. dots) refer to sub-judgment indices (resp. central points, see~\S~\ref{sec-components}). % % +\subsection{\texttt{drv\_labels\_mode}\label{sec-labels-mode}} +% +% +This macro turns the typesetting of labels on or off, whether labels are +specified or~not.\\[1ex] +\texttt{drv\_labels\_mode (\param{id 1}, \param{id 2})}\\ +\begin{tabular}{ll} +\param{id 1}& label-type identifier ({\tt ilb}, {\tt plb} or {\tt dlb})\\ +& \begin{tabular}{lll} + {\tt ilb} &inference labels& + \default[ status: {\tt on}]\\ + {\tt dlb} &delimiter labels& + \default[ status: {\tt on}]\\ + {\tt plb} &phantom steps labels& + \default[ status: {\tt on}] + \end{tabular}\\ +\param{id 2}& status identifier ({\tt on} or {\tt off}) +\end{tabular} +% +% +\subsection{\texttt{drv\_verbatimtex}\label{sec-verbatimtex}} +% +% +This macro enables the use of \LaTeX{} material that is not intended +to be typeset (e.g. \texttt{\tbs{}renewcommand} statements) by adding a +\MP{} \texttt{verbatimtex}/\texttt{etex} block to +\texttt{\param{jobname}-delayed.mp}.\\[1ex] +\texttt{drv\_verbatimtex \param{str}}\\ +\begin{tabular}{ll} +\param{str}& \LaTeX\ material +\end{tabular} +% +% \section{Pictures, bounding boxes and math axis\label{sec-pictures}} % % @@ -1216,7 +1251,7 @@ endfig; % % \texttt{drv\_axis} locally overrides \texttt{drv\_axis\_reference} (see -\S~\ref{sec-axis-reference}), allowing you to explicitly set +\S~\ref{sec-axis-reference}), enabling the explicit setting of the math axis of a tree once it has been drawn.\\[1ex] \texttt{drv\_axis (\param{id}, \param{nat})}\\ \begin{tabular}{ll} @@ -1257,9 +1292,8 @@ Notice that \texttt{drv\_axis} is irrelevant if you don't use the \paragraph{\texttt{NFR}} % % -\enlargethispage{.05\baselineskip}% -The \texttt{NFR} declaration macro is the lowest level one. It allows you to -specify all the labels and styles of an inference.\\[1ex] +The \texttt{NFR} declaration macro is the lowest level one. It enables the +specification of all the labels and styles of an inference.\\[1ex] \texttt{NFR \param{nat} (\param{nat\;list}) @@ -1340,8 +1374,8 @@ endfig; \paragraph{\texttt{MVD}} % % -The \texttt{MVD} macro is a generalization of \texttt{Mvd} that allows you to -specify the alignment style of phantom inferences.\\[1ex] +The \texttt{MVD} macro is a generalization of \texttt{Mvd} that enables the +specification of the alignment style of phantom inferences.\\[1ex] \texttt{MVD \param{nat 1} (\param{nat 2}, \param{str 1}, \param{str 2}, \param{id 1}, \param{id 2})}\\ \begin{tabular}{ll} @@ -1374,8 +1408,7 @@ endfig; \begin{gather*} \drv{drv-guide.450} \end{gather*} -\end{multicols} -\pagebreak +\end{multicols}\clearpage \begin{Verbatim} beginfig(460) jgm 0 "\textsc{Size matters -- Part 2}"; @@ -1517,29 +1550,52 @@ dimensions\label{sec-components}} % % Once \texttt{drv\_freeze} has been called, all the components of a derivation -tree are accessible independently from each-other. +tree are accessible independently from each-other. Given an inference +index~\param{nat}, you can access the inference components (provided they were +declared) via the following indentifiers. +\begin{center} +\begin{tabular}{lr} +judgment &\texttt{jdg[\param{nat}]}\\ +sub-judgments &\texttt{sbj[\param{nat}][\param{nat$'$}]}\\ +inference line &\texttt{iln[\param{nat}]}\\ +left inference label &\texttt{l\_ilb[\param{nat}]}\\ +right inference label &\texttt{r\_ilb[\param{nat}]}\\ +left delimiter &\texttt{l\_dlm[\param{nat}]}\\ +left delimiter label &\texttt{l\_dlb[\param{nat}]}\\ +right delimiter &\texttt{r\_dlm[\param{nat}]}\\ +right delimiter label &\texttt{r\_dlb[\param{nat}]}\\ +phantom steps path &\texttt{phm[\param{nat}]}\\ +left phantom steps label &\texttt{l\_plb[\param{nat}]}\\ +right phantom steps label &\texttt{l\_plb[\param{nat}]} +\end{tabular} +\end{center} +The sub-judgment index \param{nat$'$} ranges from 0 to the number of sub-judgments minus 1. % % +\enlargethispage{\baselineskip} \begin{Verbatim} beginfig(470) % components -DCL 6 () ("", "", "", "", _, _, 0) "0"; -DCL 7 (6) ("(1)", "(2)", "(3)", "(4)", _, _, 1) "A", "B"; +DCL 5 () ("", "", "", "", _, _, 0) "A"; +DCL 6 (5) ("(1)", "(2)", "(3)", "(4)", _, _, 1) "B", "C"; +DCL 7 (MVD 6 (2, "(5)", "(6)", _, 6)) ("", "", "", "", _, _, 1) "D"; drv_freeze; % usually called by drv_tree -draw jdg[6]; % judgment 0 -draw sbj[7][0] withcolor (0, 0, 1); % sub-judgment A -draw sbj[7][1] withcolor (0, 1, 0); % sub-judgment B -draw l_ilb[7] withcolor (0, 1, 1); % left inference label (1) -draw r_ilb[7] withcolor (1, 0, 0); % right inference label (2) -draw l_dlb[7] withcolor (1, 0, 1); % left delimiter label (3) -draw r_dlb[7] withcolor (1, 1, 0); % right delimiter label (4) -draw l_dlm[7]; % left delimiter -draw iln[7]; % inference line -draw r_dlm[7]; % right delimiter +draw jdg[5]; % judgment A +draw sbj[6][0] withcolor (3, 0, 0)/3; % sub-judgment B +draw sbj[6][1] withcolor (2, 0, 0)/3; % sub-judgment C +draw iln[6] withcolor (0, 4, 0)/4; % inference line +draw l_ilb[6] withcolor (0, 3, 0)/4; % left inference label (1) +draw r_ilb[6] withcolor (0, 2, 0)/4; % right inference label (2) +draw l_dlm[6] withcolor (0, 0, 3)/3; % left delimiter +draw l_dlb[6] withcolor (0, 0, 2)/3; % left delimiter label (3) +draw r_dlm[6] withcolor (3, 0, 3)/3; % right delimiter +draw r_dlb[6] withcolor (2, 0, 2)/3; % right delimiter label (4) +draw phm[6] withcolor (0, 3, 3)/4; % phantom steps path +draw l_plb[6] withcolor (0, 2, 2)/4; % left phantom steps label (5) +draw r_plb[6] withcolor (0, 1, 1)/4; % right phantom steps label (6) +draw jdg[7]; % judgment D +draw iln[7]; % inference line endfig; \end{Verbatim} -%\begin{gather*} -%\drv{drv-guide.470}\qquad\drv{drv-guide.471} -%\end{gather*} % % \paragraph{Distinguished points} @@ -1584,7 +1640,7 @@ endfig; \subsection{\texttt{drv\_styled}\label{sec-styled}} % % -\texttt{drv\_styled} allows you to draw \MP\ paths +\texttt{drv\_styled} enables the drawing of \MP\ paths %(see~\cite[Section~4]{hobby09}) using \texttt{drv} path-styles.\\[1ex] \texttt{\param{path} drv\_styled \param{id}}\\ @@ -1596,22 +1652,22 @@ using \texttt{drv} path-styles.\\[1ex] \begin{Verbatim} beginfig(490) jgm 4 "A", "\vdash", "A"; -jgm 5 "B", "\vdash", "B"; -jgm 6 "A", ",", "A", "\multimap", "B", "\vdash", "B"; -jgm 7 "A", "\multimap", "B", "\vdash", "A", "\multimap", "B"; +jgm 5 "B", "_2", "\vdash", "B", "_3"; +jgm 6 "A", ",", "A", "\multimap", "B", "_1", "\vdash", "B", "_4"; +jgm 7 "A", "\multimap", "B", "_0", "\vdash", "A", "\multimap", "B", "_5"; nfr 4 () ("1", _); nfr 5 () ("1", _); nfr 6 (4, 5) ("\multimap_{L}", _); nfr 7 (6) ("\multimap_{R}", _); -drv_freeze; -draw (sbj[7][2].c shifted (0, -num_hg) .. - sbj[7][2].c {up} .. - sbj[6][4].c .. - sbj[5][0].c .. tension 1.05 .. - sbj[5][2].c .. - sbj[6][6].c .. - sbj[7][6].c {down} .. - sbj[7][6].c shifted (0, -num_hg)) +drv_freeze; % B +draw (sbj[7][2].c shifted (0, -num_hg) .. % 0 + sbj[7][2].c {up} .. % 0 + sbj[6][4].c .. % 1 + sbj[5][0].c .. tension 1.2 .. % 2 + sbj[5][3].c .. % 3 + sbj[6][7].c .. % 4 + sbj[7][7].c {down} .. % 5 + sbj[7][7].c shifted (0, -num_hg)) % 5 drv_styled 2 withcolor (1, 0, 0); draw drv_tree; endfig; @@ -1878,7 +1934,7 @@ the first declared root (you can override this behaviour by using % % \texttt{drv\_root} locally overrides \texttt{drv\_roots\_position} (see -\S~\ref{sec-roots-position}), allowing you to explicitly set +\S~\ref{sec-roots-position}), enabling the explicit setting of the position of a root.\\[1ex] \texttt{drv\_root (\param{nat}, \param{id})}\\ \begin{tabular}{ll} @@ -1937,6 +1993,7 @@ jdg[10].c=jdg[20].c; draw drv_tree; endfig; \end{Verbatim} +\enlargethispage{\baselineskip} (The resulting figure is in Appendix~\ref{sec-gallery} on page~\pageref{fig-overlapping}.) % @@ -1944,8 +2001,8 @@ page~\pageref{fig-overlapping}.) \section{Radial mode (beta version)\label{sec-radial}} % % -A few more tuning macros (see~\S~\ref{sec-tunings}) are available that allow -you to manipulate \emph{radial} trees rather than ``linear'' ones. +A few more tuning macros (see~\S~\ref{sec-tunings}) are available that enable +the manipulation of \emph{radial} trees rather than ``linear'' ones. % % \subsection*{\texttt{drv\_radial\_mode}} @@ -1995,7 +2052,6 @@ you to manipulate \emph{radial} trees rather than ``linear'' ones. \end{gather*} % % -\enlargethispage{1.75\baselineskip}% \subsection*{\texttt{drv\_azimuth}} % % @@ -2082,7 +2138,7 @@ Here are two simple derivation trees (figures~600,~601). Here are the \texttt{drv} version of a derivation tree found in~\cite[p.~57]{restall06} and an alternative for it (figures~610,~611). \begin{gather*} -\drv{drv-guide.610} +\hbox to 0pt{\hss{\drv{drv-guide.610}}\hss} \end{gather*} \begin{gather*} \drv{drv-guide.611} diff --git a/Master/texmf-dist/doc/metapost/drv/doc/drv.mp b/Master/texmf-dist/doc/metapost/drv/doc/drv.mp index 8323b9f00af..09cd16a41d5 100644 --- a/Master/texmf-dist/doc/metapost/drv/doc/drv.mp +++ b/Master/texmf-dist/doc/metapost/drv/doc/drv.mp @@ -1,5 +1,5 @@ -%% drv 0.96 -%% Copyright 2010 Laurent M\'ehats +%% drv 0.97 +%% Copyright 2011 Laurent M\'ehats % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -17,7 +17,7 @@ % This work consists of the file drv.mp newinternal drv_version; -drv_version:=0.96; +drv_version:=0.97; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -208,18 +208,22 @@ drv_version:=0.96; % % drv_box_mode <id> % <id> status identifier (on or off) -% on -% off % % drv_fraction_mode <id> % <id> status identifier (on or off) -% on -% off % % drv_proof_mode <id> % <id> status identifier (on or off) -% on -% off +% +% drv_labels_mode (<id 1>, <id 2>) +% <id 1> label-type identifier (ilb, plb or dlb) +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <id 2> status identifier (on or off) +% +% drv_verbatimtex <str> +% <str> LaTeX material % % drv_radial_mode <id> % <id> status identifier (on or off) @@ -463,6 +467,15 @@ vardef drv_tex[] expr tex_str= pct enddef; +vardef drv_verbatimtex expr tex_str= + write char(10)& + "% drv_verbatimtex"&char(10)&char(10)& + "verbatimtex"&char(10)& + tex_str&char(10)& + "etex;" + to delayed_tex_file; +enddef; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -584,11 +597,11 @@ vardef drv_font_size expr size_str= min_clr[2]:=1*rul_thk[2]; % Rule 15d. min_clr[3]:=1*rul_thk[3]; % for mth_sty:=0 upto 3: - sp_pct:=drv_tex[mth_sty] "\thinspace"; + sp_pct:=drv_tex[mth_sty] "\,"; % thinspace thn_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\medspace"; + sp_pct:=drv_tex[mth_sty] "\:"; % medspace med_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\thickspace"; + sp_pct:=drv_tex[mth_sty] "\;"; % thickspace thk_sp[mth_sty]:=width sp_pct; pdt_pct:=drv_tex[mth_sty] "\ldotp"; pdt_hg[mth_sty]:=height pdt_pct; @@ -750,23 +763,44 @@ vardef text_arc (expr pct, rad) expr tnum= string tok_str; arc_pct:=nullpicture; for tok within pct: - transform tok_trn; - tok_str:=textpart tok; - (0, 0) transformed tok_trn=(0, 0); - (0, 1) transformed tok_trn=(xypart tok, yypart tok); - (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); - tok_ngl:=arc_angle (rad, xpart tok) tnum; - for chr_rnk=0 upto (length tok_str-1): - chr_pct:=substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) - transformed tok_trn; - hlf_wd:=(width chr_pct)/2; - tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; - addto arc_pct also chr_pct - shifted (-hlf_wd, 0) - rotated (tok_ngl+tnum*90) - shifted ((dir tok_ngl) scaled (rad-tnum*(ypart tok))); - tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; - endfor + if textual tok: + transform tok_trn; + tok_str:=textpart tok; + (0, 0) transformed tok_trn=(0, 0); + (0, 1) transformed tok_trn=(xypart tok, yypart tok); + (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); + tok_ngl:=arc_angle (rad, xpart tok) tnum; + for chr_rnk=0 upto (length tok_str-1): + chr_pct:= + substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) + transformed tok_trn; + hlf_wd:=(width chr_pct)/2; + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + addto arc_pct also chr_pct + shifted (-hlf_wd, 0) + rotated (tok_ngl+tnum*90) + shifted (dir tok_ngl scaled (rad-tnum*(ypart tok))); + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + endfor + elseif stroked tok: + path pth; + pair src, tgt; + numeric src_ngl, tgt_ngl; + pth:=pathpart tok; + src:=point 0 of pth; + tgt:=point length pth of pth; + src_ngl:=arc_angle (rad, xpart src) tnum; + tgt_ngl:=arc_angle (rad, xpart tgt) tnum; + interim linecap:=butt; + addto arc_pct doublepath + if xpart src<>xpart tgt: % horizontal rule + (circ_path (rad-tnum*(ypart src), tgt_ngl-src_ngl) tnum) + rotated src_ngl + else: % vertical rule + pth shifted -src rotated (src_ngl+tnum*90) + shifted (dir src_ngl scaled (rad-tnum*(ypart src))) + fi withpen penpart tok; + fi endfor arc_pct enddef; @@ -1030,6 +1064,10 @@ string drv_alg_sty; % default junction style numeric drv_iln_sty; % default inference line path-style numeric drv_phm_sty; % default phantom steps path-style +boolean drv_ilb_on; % inference labels on +boolean drv_dlb_on; % delimiter labels on +boolean drv_plb_on; % phantom steps labels on + % % 2. Macros % @@ -1198,13 +1236,24 @@ vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) % % lilb, rilb: inference labels % - opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; - opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + if drv_ilb_on: + opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; + opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + fi % % ldlb, rdlb: delimiter labels % - opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; - opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + if drv_dlb_on: + opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; + opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + else: + if ldlb<>"": + box_init l_dlb[@] (mth_tex[dlb_sty[drv_sty]] "{}"); + fi + if rdlb<>"": + box_init r_dlb[@] (mth_tex[dlb_sty[drv_sty]] "{}"); + fi + fi % % j_sty, a_sty and i_sty: junction, alignment and inference styles % @@ -1246,8 +1295,10 @@ vardef MVD[] (expr inf_num, lplb, rplb) (suffix a_sty, p_sty)= % % lplb, rplb: phantom steps labels % - opt_init[plb_sty[drv_sty]] l_plb[phm_idx] lplb; - opt_init[plb_sty[drv_sty]] r_plb[phm_idx] rplb; + if drv_plb_on: + opt_init[plb_sty[drv_sty]] l_plb[@] lplb; + opt_init[plb_sty[drv_sty]] r_plb[@] rplb; + fi phm_idx fi enddef; @@ -1872,32 +1923,33 @@ vardef drv_lin_build[]= % phantom steps % if known tgt[@]: - save bot_y, top_y, phm_pct; - numeric bot_y, top_y; + save trg, bot_y, top_y, phm_pct; + numeric trg, bot_y, top_y; picture phm_pct; + trg:=tgt[@]; if bot_jdg[@]: bot_y:=min_y[@]+min_clr_scl*min_clr[drv_sty]/2; - top_y:=min_y[tgt[@]]; + top_y:=min_y[trg]; else: - bot_y:=max_y[tgt[@]]; + bot_y:=max_y[trg]; top_y:=max_y[@]-min_clr_scl*min_clr[drv_sty]/2; fi phm_pct:=((0, (bot_y-top_y)/2)--(0, (top_y-bot_y)/2)) drv_styled phm_sty[@]; - box_init phm[@] (phm_pct shifted ((width phm_pct)/2, 0)); - phm[@].c=(xpart jdg[@].c, (top_y+bot_y)/2); - nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[@].l); - nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[@].r); + box_init phm[trg] (phm_pct shifted ((width phm_pct)/2, 0)); + phm[trg].c=(xpart jdg[@].c, (top_y+bot_y)/2); + nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[trg].l); + nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[trg].r); % % phantom steps labels % - if known l_plb[@]: - l_plb[@].r=phm[@].l shifted (-plb_skp[drv_sty], 0); - nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[@].l); + if known l_plb[trg]: + l_plb[trg].r=phm[trg].l shifted (-plb_skp[drv_sty], 0); + nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[trg].l); fi - if known r_plb[@]: - r_plb[@].l=phm[@].r shifted ( plb_skp[drv_sty], 0); - nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[@].r); + if known r_plb[trg]: + r_plb[trg].l=phm[trg].r shifted ( plb_skp[drv_sty], 0); + nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[trg].r); fi fi % @@ -2012,22 +2064,23 @@ vardef drv_rad_build[]= % phantom steps % if known tgt[@]: - save src_rad, tgt_rad; - numeric src_rad, tgt_rad; + save trg, src_rad, tgt_rad; + numeric trg, src_rad, tgt_rad; + trg:=tgt[@]; src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; - tgt_rad:=min_rad[tgt[@]]; - phm[@].rad=(src_rad+tgt_rad)/2; - phm[@].org=jdg[@].org; + tgt_rad:=min_rad[trg]; + phm[trg].rad=(src_rad+tgt_rad)/2; + phm[trg].org=jdg[@].org; % % phantom steps labels % - if known l_plb[@]: - l_plb[@].rad=phm[@].rad; - l_plb[@].org=phm[@].org; + if known l_plb[trg]: + l_plb[trg].rad=phm[trg].rad; + l_plb[trg].org=phm[trg].org; fi - if known r_plb[@]: - r_plb[@].rad=phm[@].rad; - r_plb[@].org=phm[@].org; + if known r_plb[trg]: + r_plb[trg].rad=phm[trg].rad; + r_plb[trg].org=phm[trg].org; fi fi % @@ -2201,43 +2254,44 @@ vardef drv_ngl_build[]= % phantom steps % if known tgt[@]: - save phm_pct, src_rad, tgt_rad; + save trg, src_rad, tgt_rad, phm_pct; + numeric trg, src_rad, tgt_rad; picture phm_pct; - numeric src_rad, tgt_rad; + trg:=tgt[@]; src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; - tgt_rad:=min_rad[tgt[@]]; + tgt_rad:=min_rad[trg]; phm_pct:=((0, (src_rad-tgt_rad)/2)--(0, (tgt_rad-src_rad)/2)) drv_styled phm_sty[@]; - arc_init phm[@] ( + arc_init phm[trg] ( phm_pct - rotated (tnum*90+arc_angle (phm[@].rad, (width phm_pct)/2) tnum) - shifted ((dir 0) scaled phm[@].rad), - arc_angle (phm[@].rad, width phm_pct) tnum); - phm[@].cng=jdg[@].cng; + rotated (tnum*90+arc_angle (phm[trg].rad, (width phm_pct)/2) tnum) + shifted ((dir 0) scaled phm[trg].rad), + arc_angle (phm[trg].rad, width phm_pct) tnum); + phm[trg].cng=jdg[@].cng; nfr_lmost_ppt[@]:=lmost_ppt (nfr_lmost_ppt[@], - (phm[@].rad, phm[@].lng)) tnum; + (phm[trg].rad, phm[trg].lng)) tnum; nfr_rmost_ppt[@]:=rmost_ppt (nfr_rmost_ppt[@], - (phm[@].rad, phm[@].rng)) tnum; + (phm[trg].rad, phm[trg].rng)) tnum; % % phantom steps labels % - if known l_plb[@]: - arc_init l_plb[@]( - text_arc (l_plb[@], l_plb[@].rad) tnum, - arc_angle (l_plb[@].rad, width l_plb[@]) tnum); - l_plb[@].rng=phm[@].lng - -arc_angle (l_plb[@].rad, plb_skp[drv_sty]) tnum; + if known l_plb[trg]: + arc_init l_plb[trg]( + text_arc (l_plb[trg], l_plb[trg].rad) tnum, + arc_angle (l_plb[trg].rad, width l_plb[trg]) tnum); + l_plb[trg].rng=phm[trg].lng + -arc_angle (l_plb[trg].rad, plb_skp[drv_sty]) tnum; nfr_lmost_ppt[@]:= - lmost_ppt(nfr_lmost_ppt[@], (l_plb[@].rad, l_plb[@].lng)) tnum; + lmost_ppt(nfr_lmost_ppt[@], (l_plb[trg].rad, l_plb[trg].lng)) tnum; fi - if known r_plb[@]: - arc_init r_plb[@]( - text_arc (r_plb[@], r_plb[@].rad) tnum, - arc_angle (r_plb[@].rad, width r_plb[@]) tnum); - r_plb[@].lng=phm[@].rng - +arc_angle (r_plb[@].rad, plb_skp[drv_sty]) tnum; + if known r_plb[trg]: + arc_init r_plb[trg]( + text_arc (r_plb[trg], r_plb[trg].rad) tnum, + arc_angle (r_plb[trg].rad, width r_plb[trg]) tnum); + r_plb[trg].lng=phm[trg].rng + +arc_angle (r_plb[trg].rad, plb_skp[drv_sty]) tnum; nfr_rmost_ppt[@]:= - rmost_ppt(nfr_rmost_ppt[@], (r_plb[@].rad, r_plb[@].rng)) tnum; + rmost_ppt(nfr_rmost_ppt[@], (r_plb[trg].rad, r_plb[trg].rng)) tnum; fi fi % @@ -2582,7 +2636,7 @@ vardef drv_bbox[]= else: (ngl_part sub_lmost_ppt[@])-arc_angle (rad_part sub_lmost_ppt[@], - jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum fi; r_ngl:= if known r_dlm[@].lng: @@ -2591,7 +2645,7 @@ vardef drv_bbox[]= else: (ngl_part sub_rmost_ppt[@])+arc_angle (rad_part sub_rmost_ppt[@], - jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum fi; (circ_path(max_rad[@], r_ngl-l_ngl) tnum-- reverse circ_path(min_rad[@], r_ngl-l_ngl) tnum-- @@ -2829,7 +2883,7 @@ vardef drv_labels_position_aux (suffix typ_sfx, pos_sfx)= save typ_str, idt_str, pos_str; string typ_str, idt_str, pos_str; typ_str:=str typ_sfx; - if typ_str="ilb": + if typ_str="ilb": drv_left_ilb:=check_position_left (pos_sfx, drv_left_ilb); elseif typ_str="dlb": drv_left_dlb:=check_position_left (pos_sfx, drv_left_dlb); @@ -2894,6 +2948,25 @@ vardef drv_proof_mode suffix status_sfx= drv_proofmode_on:=check_mode_on (status_sfx, drv_proofmode_on); enddef; +vardef drv_labels_mode (suffix typ_sfx, status_sfx)= + save typ_str, idt_str, pos_str; + string typ_str, idt_str, pos_str; + typ_str:=str typ_sfx; + if typ_str="ilb": + drv_ilb_on:=check_mode_on (status_sfx, drv_ilb_on); + elseif typ_str="dlb": + drv_dlb_on:=check_mode_on (status_sfx, drv_dlb_on); + elseif typ_str="plb": + drv_plb_on:=check_mode_on (status_sfx, drv_plb_on); + else: + drv_errhelp "Valid identifiers are"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (typ_str&" is not a valid label-type identifier"); + fi +enddef; + vardef drv_radial_mode suffix status_sfx= drv_radialmode_on:=check_mode_on (status_sfx, drv_radialmode_on); enddef; @@ -2932,6 +3005,9 @@ drv_right_delimiter "\rbrace"; drv_box_mode off; drv_fraction_mode on; drv_proof_mode off; +drv_labels_mode (ilb, on); +drv_labels_mode (dlb, on); +drv_labels_mode (plb, on); drv_radial_mode off; drv_scale (crv, 1); diff --git a/Master/texmf-dist/doc/metapost/drv/drv-guide.pdf b/Master/texmf-dist/doc/metapost/drv/drv-guide.pdf Binary files differindex b60e1fdee3e..76bc074a94b 100644 --- a/Master/texmf-dist/doc/metapost/drv/drv-guide.pdf +++ b/Master/texmf-dist/doc/metapost/drv/drv-guide.pdf diff --git a/Master/texmf-dist/doc/metapost/drv/sample/drv.mp b/Master/texmf-dist/doc/metapost/drv/sample/drv.mp index 8323b9f00af..09cd16a41d5 100644 --- a/Master/texmf-dist/doc/metapost/drv/sample/drv.mp +++ b/Master/texmf-dist/doc/metapost/drv/sample/drv.mp @@ -1,5 +1,5 @@ -%% drv 0.96 -%% Copyright 2010 Laurent M\'ehats +%% drv 0.97 +%% Copyright 2011 Laurent M\'ehats % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -17,7 +17,7 @@ % This work consists of the file drv.mp newinternal drv_version; -drv_version:=0.96; +drv_version:=0.97; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -208,18 +208,22 @@ drv_version:=0.96; % % drv_box_mode <id> % <id> status identifier (on or off) -% on -% off % % drv_fraction_mode <id> % <id> status identifier (on or off) -% on -% off % % drv_proof_mode <id> % <id> status identifier (on or off) -% on -% off +% +% drv_labels_mode (<id 1>, <id 2>) +% <id 1> label-type identifier (ilb, plb or dlb) +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <id 2> status identifier (on or off) +% +% drv_verbatimtex <str> +% <str> LaTeX material % % drv_radial_mode <id> % <id> status identifier (on or off) @@ -463,6 +467,15 @@ vardef drv_tex[] expr tex_str= pct enddef; +vardef drv_verbatimtex expr tex_str= + write char(10)& + "% drv_verbatimtex"&char(10)&char(10)& + "verbatimtex"&char(10)& + tex_str&char(10)& + "etex;" + to delayed_tex_file; +enddef; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -584,11 +597,11 @@ vardef drv_font_size expr size_str= min_clr[2]:=1*rul_thk[2]; % Rule 15d. min_clr[3]:=1*rul_thk[3]; % for mth_sty:=0 upto 3: - sp_pct:=drv_tex[mth_sty] "\thinspace"; + sp_pct:=drv_tex[mth_sty] "\,"; % thinspace thn_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\medspace"; + sp_pct:=drv_tex[mth_sty] "\:"; % medspace med_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\thickspace"; + sp_pct:=drv_tex[mth_sty] "\;"; % thickspace thk_sp[mth_sty]:=width sp_pct; pdt_pct:=drv_tex[mth_sty] "\ldotp"; pdt_hg[mth_sty]:=height pdt_pct; @@ -750,23 +763,44 @@ vardef text_arc (expr pct, rad) expr tnum= string tok_str; arc_pct:=nullpicture; for tok within pct: - transform tok_trn; - tok_str:=textpart tok; - (0, 0) transformed tok_trn=(0, 0); - (0, 1) transformed tok_trn=(xypart tok, yypart tok); - (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); - tok_ngl:=arc_angle (rad, xpart tok) tnum; - for chr_rnk=0 upto (length tok_str-1): - chr_pct:=substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) - transformed tok_trn; - hlf_wd:=(width chr_pct)/2; - tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; - addto arc_pct also chr_pct - shifted (-hlf_wd, 0) - rotated (tok_ngl+tnum*90) - shifted ((dir tok_ngl) scaled (rad-tnum*(ypart tok))); - tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; - endfor + if textual tok: + transform tok_trn; + tok_str:=textpart tok; + (0, 0) transformed tok_trn=(0, 0); + (0, 1) transformed tok_trn=(xypart tok, yypart tok); + (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); + tok_ngl:=arc_angle (rad, xpart tok) tnum; + for chr_rnk=0 upto (length tok_str-1): + chr_pct:= + substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) + transformed tok_trn; + hlf_wd:=(width chr_pct)/2; + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + addto arc_pct also chr_pct + shifted (-hlf_wd, 0) + rotated (tok_ngl+tnum*90) + shifted (dir tok_ngl scaled (rad-tnum*(ypart tok))); + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + endfor + elseif stroked tok: + path pth; + pair src, tgt; + numeric src_ngl, tgt_ngl; + pth:=pathpart tok; + src:=point 0 of pth; + tgt:=point length pth of pth; + src_ngl:=arc_angle (rad, xpart src) tnum; + tgt_ngl:=arc_angle (rad, xpart tgt) tnum; + interim linecap:=butt; + addto arc_pct doublepath + if xpart src<>xpart tgt: % horizontal rule + (circ_path (rad-tnum*(ypart src), tgt_ngl-src_ngl) tnum) + rotated src_ngl + else: % vertical rule + pth shifted -src rotated (src_ngl+tnum*90) + shifted (dir src_ngl scaled (rad-tnum*(ypart src))) + fi withpen penpart tok; + fi endfor arc_pct enddef; @@ -1030,6 +1064,10 @@ string drv_alg_sty; % default junction style numeric drv_iln_sty; % default inference line path-style numeric drv_phm_sty; % default phantom steps path-style +boolean drv_ilb_on; % inference labels on +boolean drv_dlb_on; % delimiter labels on +boolean drv_plb_on; % phantom steps labels on + % % 2. Macros % @@ -1198,13 +1236,24 @@ vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) % % lilb, rilb: inference labels % - opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; - opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + if drv_ilb_on: + opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; + opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + fi % % ldlb, rdlb: delimiter labels % - opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; - opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + if drv_dlb_on: + opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; + opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + else: + if ldlb<>"": + box_init l_dlb[@] (mth_tex[dlb_sty[drv_sty]] "{}"); + fi + if rdlb<>"": + box_init r_dlb[@] (mth_tex[dlb_sty[drv_sty]] "{}"); + fi + fi % % j_sty, a_sty and i_sty: junction, alignment and inference styles % @@ -1246,8 +1295,10 @@ vardef MVD[] (expr inf_num, lplb, rplb) (suffix a_sty, p_sty)= % % lplb, rplb: phantom steps labels % - opt_init[plb_sty[drv_sty]] l_plb[phm_idx] lplb; - opt_init[plb_sty[drv_sty]] r_plb[phm_idx] rplb; + if drv_plb_on: + opt_init[plb_sty[drv_sty]] l_plb[@] lplb; + opt_init[plb_sty[drv_sty]] r_plb[@] rplb; + fi phm_idx fi enddef; @@ -1872,32 +1923,33 @@ vardef drv_lin_build[]= % phantom steps % if known tgt[@]: - save bot_y, top_y, phm_pct; - numeric bot_y, top_y; + save trg, bot_y, top_y, phm_pct; + numeric trg, bot_y, top_y; picture phm_pct; + trg:=tgt[@]; if bot_jdg[@]: bot_y:=min_y[@]+min_clr_scl*min_clr[drv_sty]/2; - top_y:=min_y[tgt[@]]; + top_y:=min_y[trg]; else: - bot_y:=max_y[tgt[@]]; + bot_y:=max_y[trg]; top_y:=max_y[@]-min_clr_scl*min_clr[drv_sty]/2; fi phm_pct:=((0, (bot_y-top_y)/2)--(0, (top_y-bot_y)/2)) drv_styled phm_sty[@]; - box_init phm[@] (phm_pct shifted ((width phm_pct)/2, 0)); - phm[@].c=(xpart jdg[@].c, (top_y+bot_y)/2); - nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[@].l); - nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[@].r); + box_init phm[trg] (phm_pct shifted ((width phm_pct)/2, 0)); + phm[trg].c=(xpart jdg[@].c, (top_y+bot_y)/2); + nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[trg].l); + nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[trg].r); % % phantom steps labels % - if known l_plb[@]: - l_plb[@].r=phm[@].l shifted (-plb_skp[drv_sty], 0); - nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[@].l); + if known l_plb[trg]: + l_plb[trg].r=phm[trg].l shifted (-plb_skp[drv_sty], 0); + nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[trg].l); fi - if known r_plb[@]: - r_plb[@].l=phm[@].r shifted ( plb_skp[drv_sty], 0); - nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[@].r); + if known r_plb[trg]: + r_plb[trg].l=phm[trg].r shifted ( plb_skp[drv_sty], 0); + nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[trg].r); fi fi % @@ -2012,22 +2064,23 @@ vardef drv_rad_build[]= % phantom steps % if known tgt[@]: - save src_rad, tgt_rad; - numeric src_rad, tgt_rad; + save trg, src_rad, tgt_rad; + numeric trg, src_rad, tgt_rad; + trg:=tgt[@]; src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; - tgt_rad:=min_rad[tgt[@]]; - phm[@].rad=(src_rad+tgt_rad)/2; - phm[@].org=jdg[@].org; + tgt_rad:=min_rad[trg]; + phm[trg].rad=(src_rad+tgt_rad)/2; + phm[trg].org=jdg[@].org; % % phantom steps labels % - if known l_plb[@]: - l_plb[@].rad=phm[@].rad; - l_plb[@].org=phm[@].org; + if known l_plb[trg]: + l_plb[trg].rad=phm[trg].rad; + l_plb[trg].org=phm[trg].org; fi - if known r_plb[@]: - r_plb[@].rad=phm[@].rad; - r_plb[@].org=phm[@].org; + if known r_plb[trg]: + r_plb[trg].rad=phm[trg].rad; + r_plb[trg].org=phm[trg].org; fi fi % @@ -2201,43 +2254,44 @@ vardef drv_ngl_build[]= % phantom steps % if known tgt[@]: - save phm_pct, src_rad, tgt_rad; + save trg, src_rad, tgt_rad, phm_pct; + numeric trg, src_rad, tgt_rad; picture phm_pct; - numeric src_rad, tgt_rad; + trg:=tgt[@]; src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; - tgt_rad:=min_rad[tgt[@]]; + tgt_rad:=min_rad[trg]; phm_pct:=((0, (src_rad-tgt_rad)/2)--(0, (tgt_rad-src_rad)/2)) drv_styled phm_sty[@]; - arc_init phm[@] ( + arc_init phm[trg] ( phm_pct - rotated (tnum*90+arc_angle (phm[@].rad, (width phm_pct)/2) tnum) - shifted ((dir 0) scaled phm[@].rad), - arc_angle (phm[@].rad, width phm_pct) tnum); - phm[@].cng=jdg[@].cng; + rotated (tnum*90+arc_angle (phm[trg].rad, (width phm_pct)/2) tnum) + shifted ((dir 0) scaled phm[trg].rad), + arc_angle (phm[trg].rad, width phm_pct) tnum); + phm[trg].cng=jdg[@].cng; nfr_lmost_ppt[@]:=lmost_ppt (nfr_lmost_ppt[@], - (phm[@].rad, phm[@].lng)) tnum; + (phm[trg].rad, phm[trg].lng)) tnum; nfr_rmost_ppt[@]:=rmost_ppt (nfr_rmost_ppt[@], - (phm[@].rad, phm[@].rng)) tnum; + (phm[trg].rad, phm[trg].rng)) tnum; % % phantom steps labels % - if known l_plb[@]: - arc_init l_plb[@]( - text_arc (l_plb[@], l_plb[@].rad) tnum, - arc_angle (l_plb[@].rad, width l_plb[@]) tnum); - l_plb[@].rng=phm[@].lng - -arc_angle (l_plb[@].rad, plb_skp[drv_sty]) tnum; + if known l_plb[trg]: + arc_init l_plb[trg]( + text_arc (l_plb[trg], l_plb[trg].rad) tnum, + arc_angle (l_plb[trg].rad, width l_plb[trg]) tnum); + l_plb[trg].rng=phm[trg].lng + -arc_angle (l_plb[trg].rad, plb_skp[drv_sty]) tnum; nfr_lmost_ppt[@]:= - lmost_ppt(nfr_lmost_ppt[@], (l_plb[@].rad, l_plb[@].lng)) tnum; + lmost_ppt(nfr_lmost_ppt[@], (l_plb[trg].rad, l_plb[trg].lng)) tnum; fi - if known r_plb[@]: - arc_init r_plb[@]( - text_arc (r_plb[@], r_plb[@].rad) tnum, - arc_angle (r_plb[@].rad, width r_plb[@]) tnum); - r_plb[@].lng=phm[@].rng - +arc_angle (r_plb[@].rad, plb_skp[drv_sty]) tnum; + if known r_plb[trg]: + arc_init r_plb[trg]( + text_arc (r_plb[trg], r_plb[trg].rad) tnum, + arc_angle (r_plb[trg].rad, width r_plb[trg]) tnum); + r_plb[trg].lng=phm[trg].rng + +arc_angle (r_plb[trg].rad, plb_skp[drv_sty]) tnum; nfr_rmost_ppt[@]:= - rmost_ppt(nfr_rmost_ppt[@], (r_plb[@].rad, r_plb[@].rng)) tnum; + rmost_ppt(nfr_rmost_ppt[@], (r_plb[trg].rad, r_plb[trg].rng)) tnum; fi fi % @@ -2582,7 +2636,7 @@ vardef drv_bbox[]= else: (ngl_part sub_lmost_ppt[@])-arc_angle (rad_part sub_lmost_ppt[@], - jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum fi; r_ngl:= if known r_dlm[@].lng: @@ -2591,7 +2645,7 @@ vardef drv_bbox[]= else: (ngl_part sub_rmost_ppt[@])+arc_angle (rad_part sub_rmost_ppt[@], - jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum fi; (circ_path(max_rad[@], r_ngl-l_ngl) tnum-- reverse circ_path(min_rad[@], r_ngl-l_ngl) tnum-- @@ -2829,7 +2883,7 @@ vardef drv_labels_position_aux (suffix typ_sfx, pos_sfx)= save typ_str, idt_str, pos_str; string typ_str, idt_str, pos_str; typ_str:=str typ_sfx; - if typ_str="ilb": + if typ_str="ilb": drv_left_ilb:=check_position_left (pos_sfx, drv_left_ilb); elseif typ_str="dlb": drv_left_dlb:=check_position_left (pos_sfx, drv_left_dlb); @@ -2894,6 +2948,25 @@ vardef drv_proof_mode suffix status_sfx= drv_proofmode_on:=check_mode_on (status_sfx, drv_proofmode_on); enddef; +vardef drv_labels_mode (suffix typ_sfx, status_sfx)= + save typ_str, idt_str, pos_str; + string typ_str, idt_str, pos_str; + typ_str:=str typ_sfx; + if typ_str="ilb": + drv_ilb_on:=check_mode_on (status_sfx, drv_ilb_on); + elseif typ_str="dlb": + drv_dlb_on:=check_mode_on (status_sfx, drv_dlb_on); + elseif typ_str="plb": + drv_plb_on:=check_mode_on (status_sfx, drv_plb_on); + else: + drv_errhelp "Valid identifiers are"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (typ_str&" is not a valid label-type identifier"); + fi +enddef; + vardef drv_radial_mode suffix status_sfx= drv_radialmode_on:=check_mode_on (status_sfx, drv_radialmode_on); enddef; @@ -2932,6 +3005,9 @@ drv_right_delimiter "\rbrace"; drv_box_mode off; drv_fraction_mode on; drv_proof_mode off; +drv_labels_mode (ilb, on); +drv_labels_mode (dlb, on); +drv_labels_mode (plb, on); drv_radial_mode off; drv_scale (crv, 1); diff --git a/Master/texmf-dist/doc/metapost/drv/template/drv.mp b/Master/texmf-dist/doc/metapost/drv/template/drv.mp index 8323b9f00af..09cd16a41d5 100644 --- a/Master/texmf-dist/doc/metapost/drv/template/drv.mp +++ b/Master/texmf-dist/doc/metapost/drv/template/drv.mp @@ -1,5 +1,5 @@ -%% drv 0.96 -%% Copyright 2010 Laurent M\'ehats +%% drv 0.97 +%% Copyright 2011 Laurent M\'ehats % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -17,7 +17,7 @@ % This work consists of the file drv.mp newinternal drv_version; -drv_version:=0.96; +drv_version:=0.97; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -208,18 +208,22 @@ drv_version:=0.96; % % drv_box_mode <id> % <id> status identifier (on or off) -% on -% off % % drv_fraction_mode <id> % <id> status identifier (on or off) -% on -% off % % drv_proof_mode <id> % <id> status identifier (on or off) -% on -% off +% +% drv_labels_mode (<id 1>, <id 2>) +% <id 1> label-type identifier (ilb, plb or dlb) +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <id 2> status identifier (on or off) +% +% drv_verbatimtex <str> +% <str> LaTeX material % % drv_radial_mode <id> % <id> status identifier (on or off) @@ -463,6 +467,15 @@ vardef drv_tex[] expr tex_str= pct enddef; +vardef drv_verbatimtex expr tex_str= + write char(10)& + "% drv_verbatimtex"&char(10)&char(10)& + "verbatimtex"&char(10)& + tex_str&char(10)& + "etex;" + to delayed_tex_file; +enddef; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -584,11 +597,11 @@ vardef drv_font_size expr size_str= min_clr[2]:=1*rul_thk[2]; % Rule 15d. min_clr[3]:=1*rul_thk[3]; % for mth_sty:=0 upto 3: - sp_pct:=drv_tex[mth_sty] "\thinspace"; + sp_pct:=drv_tex[mth_sty] "\,"; % thinspace thn_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\medspace"; + sp_pct:=drv_tex[mth_sty] "\:"; % medspace med_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\thickspace"; + sp_pct:=drv_tex[mth_sty] "\;"; % thickspace thk_sp[mth_sty]:=width sp_pct; pdt_pct:=drv_tex[mth_sty] "\ldotp"; pdt_hg[mth_sty]:=height pdt_pct; @@ -750,23 +763,44 @@ vardef text_arc (expr pct, rad) expr tnum= string tok_str; arc_pct:=nullpicture; for tok within pct: - transform tok_trn; - tok_str:=textpart tok; - (0, 0) transformed tok_trn=(0, 0); - (0, 1) transformed tok_trn=(xypart tok, yypart tok); - (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); - tok_ngl:=arc_angle (rad, xpart tok) tnum; - for chr_rnk=0 upto (length tok_str-1): - chr_pct:=substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) - transformed tok_trn; - hlf_wd:=(width chr_pct)/2; - tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; - addto arc_pct also chr_pct - shifted (-hlf_wd, 0) - rotated (tok_ngl+tnum*90) - shifted ((dir tok_ngl) scaled (rad-tnum*(ypart tok))); - tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; - endfor + if textual tok: + transform tok_trn; + tok_str:=textpart tok; + (0, 0) transformed tok_trn=(0, 0); + (0, 1) transformed tok_trn=(xypart tok, yypart tok); + (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); + tok_ngl:=arc_angle (rad, xpart tok) tnum; + for chr_rnk=0 upto (length tok_str-1): + chr_pct:= + substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) + transformed tok_trn; + hlf_wd:=(width chr_pct)/2; + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + addto arc_pct also chr_pct + shifted (-hlf_wd, 0) + rotated (tok_ngl+tnum*90) + shifted (dir tok_ngl scaled (rad-tnum*(ypart tok))); + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + endfor + elseif stroked tok: + path pth; + pair src, tgt; + numeric src_ngl, tgt_ngl; + pth:=pathpart tok; + src:=point 0 of pth; + tgt:=point length pth of pth; + src_ngl:=arc_angle (rad, xpart src) tnum; + tgt_ngl:=arc_angle (rad, xpart tgt) tnum; + interim linecap:=butt; + addto arc_pct doublepath + if xpart src<>xpart tgt: % horizontal rule + (circ_path (rad-tnum*(ypart src), tgt_ngl-src_ngl) tnum) + rotated src_ngl + else: % vertical rule + pth shifted -src rotated (src_ngl+tnum*90) + shifted (dir src_ngl scaled (rad-tnum*(ypart src))) + fi withpen penpart tok; + fi endfor arc_pct enddef; @@ -1030,6 +1064,10 @@ string drv_alg_sty; % default junction style numeric drv_iln_sty; % default inference line path-style numeric drv_phm_sty; % default phantom steps path-style +boolean drv_ilb_on; % inference labels on +boolean drv_dlb_on; % delimiter labels on +boolean drv_plb_on; % phantom steps labels on + % % 2. Macros % @@ -1198,13 +1236,24 @@ vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) % % lilb, rilb: inference labels % - opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; - opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + if drv_ilb_on: + opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; + opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + fi % % ldlb, rdlb: delimiter labels % - opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; - opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + if drv_dlb_on: + opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; + opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + else: + if ldlb<>"": + box_init l_dlb[@] (mth_tex[dlb_sty[drv_sty]] "{}"); + fi + if rdlb<>"": + box_init r_dlb[@] (mth_tex[dlb_sty[drv_sty]] "{}"); + fi + fi % % j_sty, a_sty and i_sty: junction, alignment and inference styles % @@ -1246,8 +1295,10 @@ vardef MVD[] (expr inf_num, lplb, rplb) (suffix a_sty, p_sty)= % % lplb, rplb: phantom steps labels % - opt_init[plb_sty[drv_sty]] l_plb[phm_idx] lplb; - opt_init[plb_sty[drv_sty]] r_plb[phm_idx] rplb; + if drv_plb_on: + opt_init[plb_sty[drv_sty]] l_plb[@] lplb; + opt_init[plb_sty[drv_sty]] r_plb[@] rplb; + fi phm_idx fi enddef; @@ -1872,32 +1923,33 @@ vardef drv_lin_build[]= % phantom steps % if known tgt[@]: - save bot_y, top_y, phm_pct; - numeric bot_y, top_y; + save trg, bot_y, top_y, phm_pct; + numeric trg, bot_y, top_y; picture phm_pct; + trg:=tgt[@]; if bot_jdg[@]: bot_y:=min_y[@]+min_clr_scl*min_clr[drv_sty]/2; - top_y:=min_y[tgt[@]]; + top_y:=min_y[trg]; else: - bot_y:=max_y[tgt[@]]; + bot_y:=max_y[trg]; top_y:=max_y[@]-min_clr_scl*min_clr[drv_sty]/2; fi phm_pct:=((0, (bot_y-top_y)/2)--(0, (top_y-bot_y)/2)) drv_styled phm_sty[@]; - box_init phm[@] (phm_pct shifted ((width phm_pct)/2, 0)); - phm[@].c=(xpart jdg[@].c, (top_y+bot_y)/2); - nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[@].l); - nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[@].r); + box_init phm[trg] (phm_pct shifted ((width phm_pct)/2, 0)); + phm[trg].c=(xpart jdg[@].c, (top_y+bot_y)/2); + nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[trg].l); + nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[trg].r); % % phantom steps labels % - if known l_plb[@]: - l_plb[@].r=phm[@].l shifted (-plb_skp[drv_sty], 0); - nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[@].l); + if known l_plb[trg]: + l_plb[trg].r=phm[trg].l shifted (-plb_skp[drv_sty], 0); + nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[trg].l); fi - if known r_plb[@]: - r_plb[@].l=phm[@].r shifted ( plb_skp[drv_sty], 0); - nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[@].r); + if known r_plb[trg]: + r_plb[trg].l=phm[trg].r shifted ( plb_skp[drv_sty], 0); + nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[trg].r); fi fi % @@ -2012,22 +2064,23 @@ vardef drv_rad_build[]= % phantom steps % if known tgt[@]: - save src_rad, tgt_rad; - numeric src_rad, tgt_rad; + save trg, src_rad, tgt_rad; + numeric trg, src_rad, tgt_rad; + trg:=tgt[@]; src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; - tgt_rad:=min_rad[tgt[@]]; - phm[@].rad=(src_rad+tgt_rad)/2; - phm[@].org=jdg[@].org; + tgt_rad:=min_rad[trg]; + phm[trg].rad=(src_rad+tgt_rad)/2; + phm[trg].org=jdg[@].org; % % phantom steps labels % - if known l_plb[@]: - l_plb[@].rad=phm[@].rad; - l_plb[@].org=phm[@].org; + if known l_plb[trg]: + l_plb[trg].rad=phm[trg].rad; + l_plb[trg].org=phm[trg].org; fi - if known r_plb[@]: - r_plb[@].rad=phm[@].rad; - r_plb[@].org=phm[@].org; + if known r_plb[trg]: + r_plb[trg].rad=phm[trg].rad; + r_plb[trg].org=phm[trg].org; fi fi % @@ -2201,43 +2254,44 @@ vardef drv_ngl_build[]= % phantom steps % if known tgt[@]: - save phm_pct, src_rad, tgt_rad; + save trg, src_rad, tgt_rad, phm_pct; + numeric trg, src_rad, tgt_rad; picture phm_pct; - numeric src_rad, tgt_rad; + trg:=tgt[@]; src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; - tgt_rad:=min_rad[tgt[@]]; + tgt_rad:=min_rad[trg]; phm_pct:=((0, (src_rad-tgt_rad)/2)--(0, (tgt_rad-src_rad)/2)) drv_styled phm_sty[@]; - arc_init phm[@] ( + arc_init phm[trg] ( phm_pct - rotated (tnum*90+arc_angle (phm[@].rad, (width phm_pct)/2) tnum) - shifted ((dir 0) scaled phm[@].rad), - arc_angle (phm[@].rad, width phm_pct) tnum); - phm[@].cng=jdg[@].cng; + rotated (tnum*90+arc_angle (phm[trg].rad, (width phm_pct)/2) tnum) + shifted ((dir 0) scaled phm[trg].rad), + arc_angle (phm[trg].rad, width phm_pct) tnum); + phm[trg].cng=jdg[@].cng; nfr_lmost_ppt[@]:=lmost_ppt (nfr_lmost_ppt[@], - (phm[@].rad, phm[@].lng)) tnum; + (phm[trg].rad, phm[trg].lng)) tnum; nfr_rmost_ppt[@]:=rmost_ppt (nfr_rmost_ppt[@], - (phm[@].rad, phm[@].rng)) tnum; + (phm[trg].rad, phm[trg].rng)) tnum; % % phantom steps labels % - if known l_plb[@]: - arc_init l_plb[@]( - text_arc (l_plb[@], l_plb[@].rad) tnum, - arc_angle (l_plb[@].rad, width l_plb[@]) tnum); - l_plb[@].rng=phm[@].lng - -arc_angle (l_plb[@].rad, plb_skp[drv_sty]) tnum; + if known l_plb[trg]: + arc_init l_plb[trg]( + text_arc (l_plb[trg], l_plb[trg].rad) tnum, + arc_angle (l_plb[trg].rad, width l_plb[trg]) tnum); + l_plb[trg].rng=phm[trg].lng + -arc_angle (l_plb[trg].rad, plb_skp[drv_sty]) tnum; nfr_lmost_ppt[@]:= - lmost_ppt(nfr_lmost_ppt[@], (l_plb[@].rad, l_plb[@].lng)) tnum; + lmost_ppt(nfr_lmost_ppt[@], (l_plb[trg].rad, l_plb[trg].lng)) tnum; fi - if known r_plb[@]: - arc_init r_plb[@]( - text_arc (r_plb[@], r_plb[@].rad) tnum, - arc_angle (r_plb[@].rad, width r_plb[@]) tnum); - r_plb[@].lng=phm[@].rng - +arc_angle (r_plb[@].rad, plb_skp[drv_sty]) tnum; + if known r_plb[trg]: + arc_init r_plb[trg]( + text_arc (r_plb[trg], r_plb[trg].rad) tnum, + arc_angle (r_plb[trg].rad, width r_plb[trg]) tnum); + r_plb[trg].lng=phm[trg].rng + +arc_angle (r_plb[trg].rad, plb_skp[drv_sty]) tnum; nfr_rmost_ppt[@]:= - rmost_ppt(nfr_rmost_ppt[@], (r_plb[@].rad, r_plb[@].rng)) tnum; + rmost_ppt(nfr_rmost_ppt[@], (r_plb[trg].rad, r_plb[trg].rng)) tnum; fi fi % @@ -2582,7 +2636,7 @@ vardef drv_bbox[]= else: (ngl_part sub_lmost_ppt[@])-arc_angle (rad_part sub_lmost_ppt[@], - jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum fi; r_ngl:= if known r_dlm[@].lng: @@ -2591,7 +2645,7 @@ vardef drv_bbox[]= else: (ngl_part sub_rmost_ppt[@])+arc_angle (rad_part sub_rmost_ppt[@], - jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum fi; (circ_path(max_rad[@], r_ngl-l_ngl) tnum-- reverse circ_path(min_rad[@], r_ngl-l_ngl) tnum-- @@ -2829,7 +2883,7 @@ vardef drv_labels_position_aux (suffix typ_sfx, pos_sfx)= save typ_str, idt_str, pos_str; string typ_str, idt_str, pos_str; typ_str:=str typ_sfx; - if typ_str="ilb": + if typ_str="ilb": drv_left_ilb:=check_position_left (pos_sfx, drv_left_ilb); elseif typ_str="dlb": drv_left_dlb:=check_position_left (pos_sfx, drv_left_dlb); @@ -2894,6 +2948,25 @@ vardef drv_proof_mode suffix status_sfx= drv_proofmode_on:=check_mode_on (status_sfx, drv_proofmode_on); enddef; +vardef drv_labels_mode (suffix typ_sfx, status_sfx)= + save typ_str, idt_str, pos_str; + string typ_str, idt_str, pos_str; + typ_str:=str typ_sfx; + if typ_str="ilb": + drv_ilb_on:=check_mode_on (status_sfx, drv_ilb_on); + elseif typ_str="dlb": + drv_dlb_on:=check_mode_on (status_sfx, drv_dlb_on); + elseif typ_str="plb": + drv_plb_on:=check_mode_on (status_sfx, drv_plb_on); + else: + drv_errhelp "Valid identifiers are"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (typ_str&" is not a valid label-type identifier"); + fi +enddef; + vardef drv_radial_mode suffix status_sfx= drv_radialmode_on:=check_mode_on (status_sfx, drv_radialmode_on); enddef; @@ -2932,6 +3005,9 @@ drv_right_delimiter "\rbrace"; drv_box_mode off; drv_fraction_mode on; drv_proof_mode off; +drv_labels_mode (ilb, on); +drv_labels_mode (dlb, on); +drv_labels_mode (plb, on); drv_radial_mode off; drv_scale (crv, 1); diff --git a/Master/texmf-dist/doc/metapost/drv/template/template.mp b/Master/texmf-dist/doc/metapost/drv/template/template.mp index 02d4448a747..5c799c73cc6 100644 --- a/Master/texmf-dist/doc/metapost/drv/template/template.mp +++ b/Master/texmf-dist/doc/metapost/drv/template/template.mp @@ -98,6 +98,9 @@ etex; % drv_fraction_mode on; % drv_proof_mode off; % drv_radial_mode off; +% drv_labels_mode (ilb, on); +% drv_labels_mode (dlb, on); +% drv_labels_mode (plb, on); % drv_scale (crv, 1); % drv_azimuth 90; diff --git a/Master/texmf-dist/metapost/drv/drv.mp b/Master/texmf-dist/metapost/drv/drv.mp index 8323b9f00af..09cd16a41d5 100644 --- a/Master/texmf-dist/metapost/drv/drv.mp +++ b/Master/texmf-dist/metapost/drv/drv.mp @@ -1,5 +1,5 @@ -%% drv 0.96 -%% Copyright 2010 Laurent M\'ehats +%% drv 0.97 +%% Copyright 2011 Laurent M\'ehats % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -17,7 +17,7 @@ % This work consists of the file drv.mp newinternal drv_version; -drv_version:=0.96; +drv_version:=0.97; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -208,18 +208,22 @@ drv_version:=0.96; % % drv_box_mode <id> % <id> status identifier (on or off) -% on -% off % % drv_fraction_mode <id> % <id> status identifier (on or off) -% on -% off % % drv_proof_mode <id> % <id> status identifier (on or off) -% on -% off +% +% drv_labels_mode (<id 1>, <id 2>) +% <id 1> label-type identifier (ilb, plb or dlb) +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <id 2> status identifier (on or off) +% +% drv_verbatimtex <str> +% <str> LaTeX material % % drv_radial_mode <id> % <id> status identifier (on or off) @@ -463,6 +467,15 @@ vardef drv_tex[] expr tex_str= pct enddef; +vardef drv_verbatimtex expr tex_str= + write char(10)& + "% drv_verbatimtex"&char(10)&char(10)& + "verbatimtex"&char(10)& + tex_str&char(10)& + "etex;" + to delayed_tex_file; +enddef; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -584,11 +597,11 @@ vardef drv_font_size expr size_str= min_clr[2]:=1*rul_thk[2]; % Rule 15d. min_clr[3]:=1*rul_thk[3]; % for mth_sty:=0 upto 3: - sp_pct:=drv_tex[mth_sty] "\thinspace"; + sp_pct:=drv_tex[mth_sty] "\,"; % thinspace thn_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\medspace"; + sp_pct:=drv_tex[mth_sty] "\:"; % medspace med_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\thickspace"; + sp_pct:=drv_tex[mth_sty] "\;"; % thickspace thk_sp[mth_sty]:=width sp_pct; pdt_pct:=drv_tex[mth_sty] "\ldotp"; pdt_hg[mth_sty]:=height pdt_pct; @@ -750,23 +763,44 @@ vardef text_arc (expr pct, rad) expr tnum= string tok_str; arc_pct:=nullpicture; for tok within pct: - transform tok_trn; - tok_str:=textpart tok; - (0, 0) transformed tok_trn=(0, 0); - (0, 1) transformed tok_trn=(xypart tok, yypart tok); - (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); - tok_ngl:=arc_angle (rad, xpart tok) tnum; - for chr_rnk=0 upto (length tok_str-1): - chr_pct:=substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) - transformed tok_trn; - hlf_wd:=(width chr_pct)/2; - tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; - addto arc_pct also chr_pct - shifted (-hlf_wd, 0) - rotated (tok_ngl+tnum*90) - shifted ((dir tok_ngl) scaled (rad-tnum*(ypart tok))); - tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; - endfor + if textual tok: + transform tok_trn; + tok_str:=textpart tok; + (0, 0) transformed tok_trn=(0, 0); + (0, 1) transformed tok_trn=(xypart tok, yypart tok); + (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); + tok_ngl:=arc_angle (rad, xpart tok) tnum; + for chr_rnk=0 upto (length tok_str-1): + chr_pct:= + substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) + transformed tok_trn; + hlf_wd:=(width chr_pct)/2; + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + addto arc_pct also chr_pct + shifted (-hlf_wd, 0) + rotated (tok_ngl+tnum*90) + shifted (dir tok_ngl scaled (rad-tnum*(ypart tok))); + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + endfor + elseif stroked tok: + path pth; + pair src, tgt; + numeric src_ngl, tgt_ngl; + pth:=pathpart tok; + src:=point 0 of pth; + tgt:=point length pth of pth; + src_ngl:=arc_angle (rad, xpart src) tnum; + tgt_ngl:=arc_angle (rad, xpart tgt) tnum; + interim linecap:=butt; + addto arc_pct doublepath + if xpart src<>xpart tgt: % horizontal rule + (circ_path (rad-tnum*(ypart src), tgt_ngl-src_ngl) tnum) + rotated src_ngl + else: % vertical rule + pth shifted -src rotated (src_ngl+tnum*90) + shifted (dir src_ngl scaled (rad-tnum*(ypart src))) + fi withpen penpart tok; + fi endfor arc_pct enddef; @@ -1030,6 +1064,10 @@ string drv_alg_sty; % default junction style numeric drv_iln_sty; % default inference line path-style numeric drv_phm_sty; % default phantom steps path-style +boolean drv_ilb_on; % inference labels on +boolean drv_dlb_on; % delimiter labels on +boolean drv_plb_on; % phantom steps labels on + % % 2. Macros % @@ -1198,13 +1236,24 @@ vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) % % lilb, rilb: inference labels % - opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; - opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + if drv_ilb_on: + opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; + opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + fi % % ldlb, rdlb: delimiter labels % - opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; - opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + if drv_dlb_on: + opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; + opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + else: + if ldlb<>"": + box_init l_dlb[@] (mth_tex[dlb_sty[drv_sty]] "{}"); + fi + if rdlb<>"": + box_init r_dlb[@] (mth_tex[dlb_sty[drv_sty]] "{}"); + fi + fi % % j_sty, a_sty and i_sty: junction, alignment and inference styles % @@ -1246,8 +1295,10 @@ vardef MVD[] (expr inf_num, lplb, rplb) (suffix a_sty, p_sty)= % % lplb, rplb: phantom steps labels % - opt_init[plb_sty[drv_sty]] l_plb[phm_idx] lplb; - opt_init[plb_sty[drv_sty]] r_plb[phm_idx] rplb; + if drv_plb_on: + opt_init[plb_sty[drv_sty]] l_plb[@] lplb; + opt_init[plb_sty[drv_sty]] r_plb[@] rplb; + fi phm_idx fi enddef; @@ -1872,32 +1923,33 @@ vardef drv_lin_build[]= % phantom steps % if known tgt[@]: - save bot_y, top_y, phm_pct; - numeric bot_y, top_y; + save trg, bot_y, top_y, phm_pct; + numeric trg, bot_y, top_y; picture phm_pct; + trg:=tgt[@]; if bot_jdg[@]: bot_y:=min_y[@]+min_clr_scl*min_clr[drv_sty]/2; - top_y:=min_y[tgt[@]]; + top_y:=min_y[trg]; else: - bot_y:=max_y[tgt[@]]; + bot_y:=max_y[trg]; top_y:=max_y[@]-min_clr_scl*min_clr[drv_sty]/2; fi phm_pct:=((0, (bot_y-top_y)/2)--(0, (top_y-bot_y)/2)) drv_styled phm_sty[@]; - box_init phm[@] (phm_pct shifted ((width phm_pct)/2, 0)); - phm[@].c=(xpart jdg[@].c, (top_y+bot_y)/2); - nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[@].l); - nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[@].r); + box_init phm[trg] (phm_pct shifted ((width phm_pct)/2, 0)); + phm[trg].c=(xpart jdg[@].c, (top_y+bot_y)/2); + nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[trg].l); + nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[trg].r); % % phantom steps labels % - if known l_plb[@]: - l_plb[@].r=phm[@].l shifted (-plb_skp[drv_sty], 0); - nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[@].l); + if known l_plb[trg]: + l_plb[trg].r=phm[trg].l shifted (-plb_skp[drv_sty], 0); + nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[trg].l); fi - if known r_plb[@]: - r_plb[@].l=phm[@].r shifted ( plb_skp[drv_sty], 0); - nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[@].r); + if known r_plb[trg]: + r_plb[trg].l=phm[trg].r shifted ( plb_skp[drv_sty], 0); + nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[trg].r); fi fi % @@ -2012,22 +2064,23 @@ vardef drv_rad_build[]= % phantom steps % if known tgt[@]: - save src_rad, tgt_rad; - numeric src_rad, tgt_rad; + save trg, src_rad, tgt_rad; + numeric trg, src_rad, tgt_rad; + trg:=tgt[@]; src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; - tgt_rad:=min_rad[tgt[@]]; - phm[@].rad=(src_rad+tgt_rad)/2; - phm[@].org=jdg[@].org; + tgt_rad:=min_rad[trg]; + phm[trg].rad=(src_rad+tgt_rad)/2; + phm[trg].org=jdg[@].org; % % phantom steps labels % - if known l_plb[@]: - l_plb[@].rad=phm[@].rad; - l_plb[@].org=phm[@].org; + if known l_plb[trg]: + l_plb[trg].rad=phm[trg].rad; + l_plb[trg].org=phm[trg].org; fi - if known r_plb[@]: - r_plb[@].rad=phm[@].rad; - r_plb[@].org=phm[@].org; + if known r_plb[trg]: + r_plb[trg].rad=phm[trg].rad; + r_plb[trg].org=phm[trg].org; fi fi % @@ -2201,43 +2254,44 @@ vardef drv_ngl_build[]= % phantom steps % if known tgt[@]: - save phm_pct, src_rad, tgt_rad; + save trg, src_rad, tgt_rad, phm_pct; + numeric trg, src_rad, tgt_rad; picture phm_pct; - numeric src_rad, tgt_rad; + trg:=tgt[@]; src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; - tgt_rad:=min_rad[tgt[@]]; + tgt_rad:=min_rad[trg]; phm_pct:=((0, (src_rad-tgt_rad)/2)--(0, (tgt_rad-src_rad)/2)) drv_styled phm_sty[@]; - arc_init phm[@] ( + arc_init phm[trg] ( phm_pct - rotated (tnum*90+arc_angle (phm[@].rad, (width phm_pct)/2) tnum) - shifted ((dir 0) scaled phm[@].rad), - arc_angle (phm[@].rad, width phm_pct) tnum); - phm[@].cng=jdg[@].cng; + rotated (tnum*90+arc_angle (phm[trg].rad, (width phm_pct)/2) tnum) + shifted ((dir 0) scaled phm[trg].rad), + arc_angle (phm[trg].rad, width phm_pct) tnum); + phm[trg].cng=jdg[@].cng; nfr_lmost_ppt[@]:=lmost_ppt (nfr_lmost_ppt[@], - (phm[@].rad, phm[@].lng)) tnum; + (phm[trg].rad, phm[trg].lng)) tnum; nfr_rmost_ppt[@]:=rmost_ppt (nfr_rmost_ppt[@], - (phm[@].rad, phm[@].rng)) tnum; + (phm[trg].rad, phm[trg].rng)) tnum; % % phantom steps labels % - if known l_plb[@]: - arc_init l_plb[@]( - text_arc (l_plb[@], l_plb[@].rad) tnum, - arc_angle (l_plb[@].rad, width l_plb[@]) tnum); - l_plb[@].rng=phm[@].lng - -arc_angle (l_plb[@].rad, plb_skp[drv_sty]) tnum; + if known l_plb[trg]: + arc_init l_plb[trg]( + text_arc (l_plb[trg], l_plb[trg].rad) tnum, + arc_angle (l_plb[trg].rad, width l_plb[trg]) tnum); + l_plb[trg].rng=phm[trg].lng + -arc_angle (l_plb[trg].rad, plb_skp[drv_sty]) tnum; nfr_lmost_ppt[@]:= - lmost_ppt(nfr_lmost_ppt[@], (l_plb[@].rad, l_plb[@].lng)) tnum; + lmost_ppt(nfr_lmost_ppt[@], (l_plb[trg].rad, l_plb[trg].lng)) tnum; fi - if known r_plb[@]: - arc_init r_plb[@]( - text_arc (r_plb[@], r_plb[@].rad) tnum, - arc_angle (r_plb[@].rad, width r_plb[@]) tnum); - r_plb[@].lng=phm[@].rng - +arc_angle (r_plb[@].rad, plb_skp[drv_sty]) tnum; + if known r_plb[trg]: + arc_init r_plb[trg]( + text_arc (r_plb[trg], r_plb[trg].rad) tnum, + arc_angle (r_plb[trg].rad, width r_plb[trg]) tnum); + r_plb[trg].lng=phm[trg].rng + +arc_angle (r_plb[trg].rad, plb_skp[drv_sty]) tnum; nfr_rmost_ppt[@]:= - rmost_ppt(nfr_rmost_ppt[@], (r_plb[@].rad, r_plb[@].rng)) tnum; + rmost_ppt(nfr_rmost_ppt[@], (r_plb[trg].rad, r_plb[trg].rng)) tnum; fi fi % @@ -2582,7 +2636,7 @@ vardef drv_bbox[]= else: (ngl_part sub_lmost_ppt[@])-arc_angle (rad_part sub_lmost_ppt[@], - jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum fi; r_ngl:= if known r_dlm[@].lng: @@ -2591,7 +2645,7 @@ vardef drv_bbox[]= else: (ngl_part sub_rmost_ppt[@])+arc_angle (rad_part sub_rmost_ppt[@], - jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum fi; (circ_path(max_rad[@], r_ngl-l_ngl) tnum-- reverse circ_path(min_rad[@], r_ngl-l_ngl) tnum-- @@ -2829,7 +2883,7 @@ vardef drv_labels_position_aux (suffix typ_sfx, pos_sfx)= save typ_str, idt_str, pos_str; string typ_str, idt_str, pos_str; typ_str:=str typ_sfx; - if typ_str="ilb": + if typ_str="ilb": drv_left_ilb:=check_position_left (pos_sfx, drv_left_ilb); elseif typ_str="dlb": drv_left_dlb:=check_position_left (pos_sfx, drv_left_dlb); @@ -2894,6 +2948,25 @@ vardef drv_proof_mode suffix status_sfx= drv_proofmode_on:=check_mode_on (status_sfx, drv_proofmode_on); enddef; +vardef drv_labels_mode (suffix typ_sfx, status_sfx)= + save typ_str, idt_str, pos_str; + string typ_str, idt_str, pos_str; + typ_str:=str typ_sfx; + if typ_str="ilb": + drv_ilb_on:=check_mode_on (status_sfx, drv_ilb_on); + elseif typ_str="dlb": + drv_dlb_on:=check_mode_on (status_sfx, drv_dlb_on); + elseif typ_str="plb": + drv_plb_on:=check_mode_on (status_sfx, drv_plb_on); + else: + drv_errhelp "Valid identifiers are"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (typ_str&" is not a valid label-type identifier"); + fi +enddef; + vardef drv_radial_mode suffix status_sfx= drv_radialmode_on:=check_mode_on (status_sfx, drv_radialmode_on); enddef; @@ -2932,6 +3005,9 @@ drv_right_delimiter "\rbrace"; drv_box_mode off; drv_fraction_mode on; drv_proof_mode off; +drv_labels_mode (ilb, on); +drv_labels_mode (dlb, on); +drv_labels_mode (plb, on); drv_radial_mode off; drv_scale (crv, 1); |