%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Example of MCF   Typeset with LuaLaTeX(luamplib)   by A.Yamaji   2025.02.16
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ** mcf2graph.mf must be version 5.19
% ** use mcf_library.mcf
% ** typeset by LuaLaTeX(luamplib)
%-------------------------------------------------------------------------
\documentclass{article}
\usepackage{luamplib}
\usepackage[T1]{fontenc}
\mplibcodeinherit{enable}
\mplibnumbersystem{double}
\mpliblegacybehavior{disabled}
%-------------------------------------------------------------------------
%\pagestyle{headings}
\topmargin=-27mm%
\oddsidemargin=-12mm%
\textwidth=190mm%
\textheight=280mm%
\parindent=0mm%
\newcount\headeroff%
\headeroff=0%
\makeatletter%
%-------------------------------------------------------------------------
\begin{document}
\begin{center}
 {\Huge\sf Molecular Coding Format examples} \vspace{4mm} \\
 Author : Akira Yamaji \quad Date : \today \quad
 Located at : http://www.ctan.org/pkg/mcf2graph \\
\end{center}
%-------------------------------------------------------------------------
\newbox \fig@box%
\newcount \fig@num%
\newcount \col@num%
\font\labelM=cmtt8 at 6pt\relax%
%-------------------------------------------------------------------------
\fig@num=0%
\col@num=0%
\unitlength=0.01mm%
%-------------------------------------------------------------------------
\newif\ifCONT@%
\CONT@true%
%-------------------------------------------------------------------------
\begin{mplibcode}
  input mcf2graph;
  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=85mm,110mm,130mm,150mm:
      draw (col_w,h)--(col_w,h-header_h) wpcs thickness_frame;
    endfor
  enddef;
%-------------------------------------------------------------------------
  loadm("EN=Benzene");
  fig_num:=0;
  beginfigm
    fsize:=(50mm,8mm);
    fmargin:=(6mm,2mm);
    mposition:=(1,0.5);
    max_blength:=3.5mm;
    row_h:=3.8mm;
    header_h:=3.8mm;
    getm(fig_num);
    if checkm(mc)=0:
      drawm(scantokens(mc))
      ext(
        defaultfont:="uhvr8r"; defaultscale:=0.5;
        label.lrt("[No]",(0,h));
        defaultscale:=0.6;
        label.lrt("Name",(w,h));
        label.rt("Molecular structure",(0mm,0.5h));
        label.lrt("Category",(85mm,h));
        label.lrt("Molecular Weight",(110mm,h));
        label.lrt("MW calculated",(130mm,h));
        label.lrt("Composition Formula calculated",(150mm,h));
        label.lrt("Molecular Coding Format",(50mm,h-11.5));
        make_frame;
      )
    fi
  endfigm
%------------------------------------------------------------------------------
  loadm("EXA=1");
  fig_num:=0;
  fsize:=(50mm,15.2mm);
  fmargin:=(8mm,0.5mm);
  max_blength:=3.3mm;
  row_h:=3.8mm;
  header_h:=3.8mm;
\end{mplibcode}
%------------------------------------------------------------------------------
\CONT@true%
\fig@num=0%
\noindent%
\loop%
\advance\fig@num\@ne\relax%
\ifnum\fig@num=539 \CONT@false%
\else%
\begin{mplibcode}%
  beginfigm
    getm(fig_num);
    if checkm(mc)=0:
      drawm(scantokens(mc))
      ext(
        defaultfont:="uhvr8r"; defaultscale:=0.8;
        label.lrt("["&decimal(fig_num)&"]",(0,2h)) scaled 0.5;
        if length(EN)>20: defaultscale:=20/length(EN)*0.8; label.lrt(EN,(w,h)); defaultscale:=0.8;
        else:             label.lrt(EN,(w,h));
        fi
        label.lrt(CAT,(85mm,h));
        label.lrt(MW,(110mm,h));
        label.lrt(mw,(130mm,h));
        label.lrt(fm,(150mm,h));
        make_frame;
        defaultfont:="cmtt9"; defaultscale:=1; row_h:=10;
        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%
%------------------------------------------------------------------------------
\newpage%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{mplibcode}
  loadm("EXA=2");
  fig_num:=0;
  fsize:=(50mm,34mm);
  fmargin:=(2mm,2mm);
  max_blength:=4mm;
  row_h:=3.8mm;
  header_h:=3.8mm;
\end{mplibcode}
%------------------------------------------------------------------------------
\noindent%
\CONT@true%
\fig@num=0%
\loop%
\advance\fig@num\@ne\relax%
\ifnum\fig@num=25 \CONT@false%
\else%
\begin{mplibcode}%
  beginfigm
    getm(fig_num);
    if checkm(mc)=0:
      drawm(scantokens(mc))
      ext(
        defaultfont:="uhvr8r"; defaultscale:=0.8;
        label.lrt("["&decimal(fig_num)&"]",(0,2h)) scaled 0.5;
        if length(EN)>20: defaultscale:=20/length(EN); label.lrt(EN,(w,h)); defaultscale:=1;
        else:             label.lrt(EN,(w,h));
        fi
        label.lrt(CAT,(85mm,h));
        label.lrt(MW,(110mm,h));
        label.lrt(mw,(130mm,h));
        label.lrt(fm,(150mm,h));
        make_frame;
        defaultfont:="cmtt9"; defaultscale:=1;
        if mc_row>12: defaultscale:=0.6; row_h:=5.8;
        ef mc_row>7:  defaultscale:=0.8; row_h:=6.5;
        ef mc_row>6:  row_h:=10;
        ef mc_row>5:  row_h:=11;
        else: row_h:=12;
        fi
        for i=1 upto mc_row: label.lrt(mc[i],(w+mc_indent[i]*4.25,h-(i-1)*row_h-12)); endfor
      )
      VerbatimTeX("\gdef\EN{"&EN&"}");
    fi
  endfigm
\end{mplibcode}\vspace{-1.2pt}\\
%------------------------------------------------------------------------
\fi%
\message{[\the\fig@num:\EN]}%
\ifCONT@ \repeat%
%------------------------------------------------------------------------------
\end{document}
