- Questo topic ha 5 risposte, 4 partecipanti ed è stato aggiornato l'ultima volta 15 anni, 6 mesi fa da .
-
Topic
-
Il nome forse dirà poco, ma l’ho scelto per motivi oscuri e non spiegabili facilmente. 🙂 Il README diceThe gmp package allows integration between MetaPost
pictures and LaTeX, the main feature is that passing
parameters to the MetaPost pictures is possible and
the picture code can be put inside arguments to
commands, including \newcommand.Mi pare un buon modo di festeggiare il messaggio numero 9000! 😀
Allego anche un file di esempio, tanto per mostrare quello che può fare; il codice MP è di Taco Hoekwater (per quello che so) e replica lo stile di intestazione dei capitoli di uno dei manuali di ConTeXt
`\documentclass[a4paper]{book}
\usepackage[shellescape]{gmp}
\usepackage{titlesec}
% macro arguments:
% #1 = desired width
% #2 = desired height
% #3 = pen thickness (relative)
% #4 = line color
% #5 = dot color
\newsavebox{\tacochapterbox}
\newcommand{\tacochapterhead}[1]{%
\sbox\tacochapterbox{\Large\bfseries #1}%
{\ooalign{%
\MPclipOne{\mpdim{\wd\tacochapterbox+6pc}}
{\mpdim{\ht\tacochapterbox+3pc}}
{8}
{(.7,.7,.7)}
{red}
\cr
\hfill\raisebox{\dimexpr.5\ht\tacochapterbox+1.5pc\relax}
{\box\tacochapterbox}\hfill}}}\def\MPclipOne#1#2#3#4#5%
{\begin{mpost}
w := #1; width := 100; wfactor := w/width;
h := #2; height := 100; hfactor := h/height;
%
color lightred; lightred := (.90,.50,.50);
color lightgray; lightgray := (.95,.95,.95);
color gray; gray := (.50,.50,.50);
%
def random_delta (expr d) =
d-(uniformdeviate 2d)
enddef;
%
z1 = (0,height);
z2 = (0,0);
z3 = (width,0);
z4 = (width,height);
%
z5 = (width+random_delta(.2width),height+random_delta(.2height));
z6 = (.5width+random_delta(.1width),height+random_delta(.1height));
%
pickup pencircle
xscaled (#3/wfactor)
yscaled (#3/(2*hfactor))
rotated 30;
%
draw z5..z1..z2..z3..z4..z6 withcolor #4;
%
pickup pencircle
xscaled (#3/wfactor)
yscaled (#3/hfactor);
%
draw z1 withcolor #5;
draw z2 withcolor #5;
draw z3 withcolor #5;
draw z4 withcolor #5;
draw z5 withcolor #5;
draw z6 withcolor #5;
%
newwidth := (xpart (urcorner currentpicture)) –
(xpart (llcorner currentpicture));
newheight := (ypart (urcorner currentpicture)) –
(ypart (llcorner currentpicture));
%
currentpicture := currentpicture
xscaled (w/newwidth) yscaled (h/newheight);
\end{mpost}}\newcommand{\chapformat}[1]{\tacochapterhead{\thechapter. #1}}
\titleformat{name=\chapter}[block]
{\large\bfseries\filcenter}{}{1em}{\chapformat}
\titleformat{name=\chapter,numberless}[block]
{\large\bfseries\filcenter}{}{1em}{\tacochapterhead}\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{How to draw graphics}Hello world!
\end{document}`
Va compilato con “pdflatex -shell-escape”; si può vedere il risultato qui. Buon divertimento!Ciao
Enrico
- Devi essere connesso per rispondere a questo topic.
