summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/mcf2graph/mcf_example.tex
blob: 53ae0a1e17c85fbd9c98e60fdfdfc72824900ef1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Example of MCF   Typeset with LuaLaTeX(luamplib)   by A.Yamaji   2024.01.03
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ** mcf2graph.mf must be version 5.10
% ** use mcf_library.mcf
% ** typeset by LuaLaTeX(luamplib)
%-------------------------------------------------------------------------
\documentclass{article}
\usepackage{luamplib}
\usepackage[T1]{fontenc}
\mplibcodeinherit{enable}
\mplibnumbersystem{double}
\mpliblegacybehavior{disabled}
%-------------------------------------------------------------------------
\pagestyle{empty}
\topmargin=-24mm
\oddsidemargin=-12mm
\textwidth=192mm
\textheight=280mm
\parindent=0mm
\newcount\headeroff
\headeroff=0
\makeatletter
%-------------------------------------------------------------------------
\begin{document}
\ifnum\z@=\headeroff%
\begin{center}
 {\Huge\sf Molecular Coding Format examples} \vspace{5mm} \\
 Author : Akira Yamaji \quad Date : \today \\
 Located at : http://www.ctan.org/pkg/mcf2graph
\end{center}
{\small *use 'mcf2grapf.mp' ver 5.10  \quad
        *typeset with LuaLaTeX \quad
        *use molecular library file 'main\_lib.mcf' \\
        ** FM(fm):molecular formula (calculated) \quad 
        * MW(mw):molecular weight (calculated)} \vspace{3mm} \\
\fi%
%-------------------------------------------------------------------------
\noindent%
\newbox \fig@box%
\newcount \fig@num%
\newcount \col@num%
\font\labelM=cmtt8 at 6pt\relax%
%-------------------------------------------------------------------------
\fig@num=0%
\col@num=0%
\unitlength=0.01mm%
\noindent%
%-------------------------------------------------------------------------
\newif\ifCONT@%
\CONT@true%
%-------------------------------------------------------------------------
\begin{mplibcode}
  input mcf2graph;
  sw_output:=Fig+Calc;
  fsize:=(35mm,24mm);
  max_blength:=4mm;
  loadm("EXA=1");
\end{mplibcode}
%-------------------------------------------------------------------------
\loop%
\advance\fig@num\@ne\relax%
\advance\col@num\@ne\relax%
\ifnum\fig@num=276 \CONT@false%
\else%
\sbox{\fig@box}{%
\begin{mplibcode}
  beginfigm
    getm(fig_num);
    if checkm(mc)=0:
      drawm(scantokens(mc))
      VerbatimTeX("\gdef\EN{"&EN&"}");
      VerbatimTeX("\gdef\MW{"&MW&"}");
      VerbatimTeX("\gdef\mw{"&mw&"}");
      VerbatimTeX("\gdef\fm{"&fm&"}");
    fi
  endfigm
\end{mplibcode}
}%
%------------------------------------------------------------------------
  \message{[\the\fig@num:\EN]}%
  \begin{picture}(3750,3350)%
    \put(20,3000){\footnotesize\bf \EN}%
    \put(20,2750){\labelM MW:\MW { / }fm:\fm}%
    \put(20,2530){\labelM mw:\mw { / }[\the\fig@num]}%
    \put(0,0){\makebox(3750,2530){\usebox{\fig@box}}}%
  \end{picture}%
  \ifnum\col@num=5 \\ \col@num=\z@ \fi%
\fi%
%------------------------------------------------------------------------
\ifCONT@\repeat%
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{mplibcode}
  loadm("EXA=2");
  fig_num:=0;
  fsize:=(50mm,34mm);
  fmargin:=(1mm,1mm);
  max_blength:=4mm;
  row_h:=3.8mm;
  header_h:=3.8mm;
  def make_frame=
    draw (0,0)--(185mm,0)--(185mm,h)--(0,h)--cycle wpcs thickness_frame;
    draw (w,h-header_h)--(185mm,h-header_h) wpcs thickness_frame;
    draw (w,h)--(w,0) wpcs thickness_frame;
    for col_w=75mm,105mm,130mm,155mm:
      draw (col_w,h)--(col_w,h-header_h) wpcs thickness_frame;
    endfor
  enddef;
\end{mplibcode}
%------------------------------------------------------------------------------
\noindent%
\CONT@true%
\fig@num=0%
\loop%
\advance\fig@num\@ne\relax%
\ifnum\fig@num=9 \CONT@false%
\else%
\begin{mplibcode}%
  beginfigm
    getm(fig_num);
    if checkm(mc)=0:
      drawm(scantokens(mc))
      ext(
        defaultfont:="cmtt9";
        label.lrt("["&decimal(fig_num)&"]",(0,h));
        label.llft(EXA,(w,h));
        if length(EN)>23:
          nA:=defaultscale;
          defaultscale:=23/length(EN); label.lrt(EN, (w,h));
          defaultscale:=nA;
        else:
          label.lrt(EN, (w,h));
        fi
        label.lrt(CAT,(75mm,h));
        label.lrt(MW,(105mm,h));
        label.lrt(mw,(130mm,h));
        label.lrt(fm,(155mm,h));
        make_frame;
        if mc_row>12: defaultscale:=0.6; row_h:=5.25;
        ef mc_row>8:  defaultscale:=0.8; row_h:=6.5;
        else: row_h:=10;
        fi
        for i=1 upto mc_row:
          label.lrt(mc[i],(w+mc_indent[i]*4.25,h-(i-1)*row_h-11.5));
        endfor
      )
      VerbatimTeX("\gdef\EN{"&EN&"}");
   fi
  endfigm
\end{mplibcode}\vspace{-1.2pt}\\
%------------------------------------------------------------------------
\fi%
\message{[\the\fig@num:\EN]}%
\ifCONT@ \repeat%
%------------------------------------------------------------------------------
\end{document}