寻找 ConTeXt 示例

寻找 ConTeXt 示例

在互联网上,你可以在以下网站上找到大量可直接排版的 LaTeX 示例(通常称为模板):LaTeX 模板或者背页. 这些可以让新手快速制作文档,而高级用户可以了解如何实现特定的布局。

ConTeXt 由一家公司开发,其发展势头比 LaTeX 强劲得多,并且提供了 LaTeX 目前无法实现的有趣功能。另一个引人注目的地方是其基本一致的语法,本质上就是\setup...\start...\stop...。更多理由请见主题我为什么应该对 ConTeXt 感兴趣?

ConTeXt 也有详尽的文档,请参阅哪里可以找到好的 ConTeXt 文档但我缺少具体的例子,例如

  • 如何在 ConTeXt 中撰写简历?
  • 如何在 ConTeXt 中制作会议海报?
  • 如何在 ConTeXt 中设计演示幻灯片?

基本上,所有类别的示例都列在LaTeX 模板

答案1

这是一个真实的例子。我是一名学者,我使用 ConTeXt 撰写资助提案。格式指南相对简单(使用此字体,设置这些边距,仅此而已)。我通常向两个资助机构提交,FRQNT 和 NSERC,它们的格式说明略有不同。偶尔,我也会写一份通用提案提交给其他机构。

我有一个私有模块p-proposal来处理不同的格式要求。由于这是供个人使用的,因此大部分内容都没有记录。我在评论中添加了简短的解释;如果有什么不明白的地方,请随时提问:

\startmodule proposal

\setupmodule[size=10pt, alternative=default]

\processaction
  [\currentmoduleparameter{alternative}]
  [
    default=>{\enablemode[compact]},
    frqnt=>{\enablemode[frqnt]},
    nserc=>{\enablemode[nserc]},
  ]

% Grants to FRQNT should be in 10bp. 
\startmode[frqnt]
  \setupmodule[site=10bp]
\stopmode

% Grants to NSERC should be in 12pt.
\startmode[nserc]
  \setupmodule[size=12pt]
\stopmode

% Enable microtype protrusion. 
\definefontfeature
  [default]
  [default]
  [protrusion=quality,expansion=quality]

\setupalign[hanging,tolerant]

% Most grant agencies want Times. Use MS Times rather than
% some other clone like Termes; I once had a grant application
% returned because pdffonts didn't list Times!
\usetypescriptfile[mscore]
\usetypescriptfile[texgyre]
\usetypescriptfile[euler]

\starttypescript[mainface]
  \definetypeface [mainface][rm][serif][mscoretimes][default]
  \definetypeface [mainface][ss][sans] [helvetica][default] [rscale=auto]
  \definetypeface [mainface][tt][mono] [modern]   [default] [rscale=auto]
  \definetypeface [mainface][mm][math] [pagellaovereuler]  [default]
                  [rscale=0.9]
\stoptypescript

% I tend to use math sparingly, therefore the math font is Euler. 
% Set all math characters to be upright rather than italic.
\setupmathematics[default=normal, lcgreek=normal, ucgreek=normal]

% I don't like Euler bullets (when used in itemize); take bullets
% from the text font instead.
\setupsymbolset[text]

% MS Times does not have small caps. The headers are typeset in small caps.
% So, use Termes for headers.
\starttypescript[headerface]
  \definetypeface [headerface][rm][serif][termes][default]
  \definetypeface [headerface][ss][sans] [helvetica][default] [rscale=auto]
  \definetypeface [headerface][tt][mono] [modern]   [default] [rscale=auto]
  \definetypeface [headerface][mm][math] [pagellaovereuler]  [default] [rscale=auto]
\stoptypescript

\setupbodyfont[headerface] % To initialize the header font globally
\setupbodyfont[mainface,\currentmoduleparameter{size}]

% \em should be italic rather than slanted.
\definebodyfontenvironment[default][em=italic]  

% Many funding agencies cannot handle a higher PDF version, sigh!
\pdfminorversion 4

\setuppapersize[letter][letter]

\setuplayout[
                   width=middle,
                  height=middle,
                location=middle,
                topspace=0.75in,
             bottomspace=0.75in,
                  bottom=0.25in,
               backspace=1in,
                cutspace=1in,
              leftmargin=.45in,
             rightmargin=.45in,
      leftmargindistance=0.05in,
     rightmargindistance=0.05in,
                  header=0.20in,
                  footer=0.20in,
           headerdistance=0.05in,
          footerdistance=0.05in,
        ]

\startmode[compact,frqnt, nserc]
  \setuplayout
    [
      topspace=0.5in, bottomspace=0.5in, 
      backspace=0.75in, cutspace=0.75in, width=middle,
      footer=0pt, footerdistance=0pt,
    ]
\stopmode

\startmode[frqnt,nserc]
  \setupinterlinespace[line=12.25bp]
\stopmode

\setuppagenumbering[location=]
\setupheader[style={\switchtobodyfont[headerface]\sc}]
\setupfooter[style={\switchtobodyfont[headerface]\sc}]
\setupbottom[style={\switchtobodyfont[headerface]\sc}]

\setupbackgrounds[header][text][bottomframe=on]

\startmode[compact]
  \setuphead[section,subject]
            [number=no, style=bold, alternative=text,before={\blank[small]},distance=0.25em,after=]
  \def\deepstructuretitlecommand#1{#1:}
\stopmode

\setuphead[title][alternative=middle, style=\ssbfb]

\startnotmode[compact]
  \setuphead[section,subject]
            [style=\ssbfa, before={\blank[big]}, after={\blank[medium]}]
  \setuphead[subsection,subsubject]
            [style=\ssbf, before={\blank[medium]}, after={\blank[small]}]
\stopnotmode

\startmode[frqnt, nserc]
  \setuphead[section,subject]
            [style=\bfa,before={\blank[small]}, after={\blank[none]}]
  \setuphead[subsection,subsubsection]
            [style=\bf,%alternative=text,
             deeptextcommand=\groupedcommand{}{\removeunwantedspaces:}, 
             distance=1ex,
             before={\blank[small]}]

  \setuphead[subsection,subsubsection, subsubsubsection, subsubject]
            [style=\bf,alternative=text,
             deeptextcommand=\groupedcommand{}{\removeunwantedspaces:}, 
             distance=1ex,
             before={\blank[small]}]
\stopmode

% Be more linient with hyphenation.
\definebreakpoint [compound] [-] [nleft=2,nright=2]
\setbreakpoints   [compound]

\setupindenting[medium,yes]
\setupwhitespace[none]
\setupblank[halfline]

\startmode[compact]
  \setupitemize[nowhite]
  \setupitemize[margin=2em]
\stopmode

\definehighlight[important][style=bolditalic]
\definecolor[lightyellow][r=1,g=1,b=0.88]

\setupframedtext
  [
    width=broad,
    offset=5bp,
    align={hanging,hz},
    background={color},
    backgroundcolor=lightyellow,
    rulethickness=1bp,
    frame=on,
    framecolor=black,
  ]

\setupitemize[autointro, broad, fit]
\setupitemize[distance=0.5em, indentnext=auto]

\definetabulate[titletabulate][|k0lB|i1p|]
\setuptabulate[titletabulate][unit=0.25em]

\setupcaptions[style={\small\setupinterlinespace}, distance=0.5em]
\setupfloats[sidespaceafter=0pt]

\setupformula 
    [
      spacebefore={nowhite,fixed,quarterline}, 
      spaceafter={back,fixed,nowhite,halfline},
    ]

\stopmodule

为了显示输出,我使用以下测试文件:

% Change the alternative for different results
\usemodule[proposal][alternative=default]

% The header should be the title of the grant and the PIN of the PI
\startmode[nserc,frqnt]
  \setupheadertexts[\fakewords{3}{4}][PIN: 12345]
\stopmode

\usemodule[visual]

\starttext
%In the generic proposal, the title is given at the top
\startnotmode[frqnt,nserc]
\starttitletabulate
  \NC Project \NC \fakewords{5}{10}  \NC \NR
  \NC Investigators \NC \fakewords{3}{5}  \NC \NR
\stoptitletabulate
\stopnotmode

\dorecurse{6}
  {\section{\fakewords{3}{7}}
   \dorecurse{2}
     {\fakewords{100}{200}\endgraf
     \placefigure[left]{\fakewords{4}{8}}{\fakeimage{4cm}{3cm}{5cm}{6cm}}
     \dorecurse{2}{\fakewords{100}{200}\endgraf}}}

\stoptext

输出alternative=frqnt

在此处输入图片描述

输出alternative=nserc几乎相同,但使用更大的字体:

在此处输入图片描述

使用alternative=default,输出为:

在此处输入图片描述

答案2

这是我的。它仍然是工作正在进行中,我正在设法用阿拉伯语/法语添加一个带有徽标的标题\framed


 \setuppapersize[A4]
 \mainlanguage[fr]
 \usemodule[chart]
  %\setuplayout[backspace=3.5cm,width=14cm]
   \usesymbols[fontawesome]
   \setuppagenumbering[alternative=doublesided,location=]
   %\setupheader[text][after=\hrule]
   %\setupheadertexts[]
   %\setupheadertexts[\setups{text a}][][\setups{text b}][]
   %\startsetups[text a]
   %  \hskip-1.5cm
   %  \framed[frame=off,width=17cm,offset=none]{
    %  \rlap{Cardiologie} 
   %  \hfill
   %  {\darkred \ss Clinique EL ABRAR}
   %  \hfill
   %  \llap{\pagenumber}}
   %\stopsetups
   %\startsetups[text b]
   %  \hskip-1.5cm
   %  \framed[frame=off,width=17cm,offset=none]{
   %  \rlap{\tfxx \ss 15 Rue Tolozane Les Palmiers, Oran}
   %  \hfill
   %  {Clinique EL ABRAR}
   %  \hfill
   %  \llap{\pagenumber}}
   %\stopsetups
   \definecolor[abrar][r=0.02,g=0.49,b=0.52]
   \definefontfeature[default][default][onum=yes]
   %\definefallbackfamily [texgyre] [serif] [amiriregular] [range=arabic]
   %\define[1]\Arab{\setuplayout[r2l] \texgyre#1}
   \definefontfamily[texgyre][serif][merriweather]
   \definefontfamily[texgyre][sans] [merriweathersans]
   \definefontfamily[texgyre][mono] [TeX Gyre Cursor][features=none]
   \definefontfamily[texgyre][math] [TeX Gyre Pagella Math]
   \setupbodyfont[texgyre,11pt]
   \setupfootertexts[\tfx Rapport médical --- Page \currentpage\ de               \lastpage  ---  Le \currentdate]
   \setuphead[subject][color=abrar,style=\ssb \bf] 
   \setuphead[subsubject][color=abrar, style=\ss\tfb\bi]
   \edef\defaultlineheight{\the\lineheight}
   \startMPdefinitions
    newpath basicShape;
    basicShape := unitsquare ;

    DefaultLineHeight := \defaultlineheight;
   \stopMPdefinitions

   \startuseMPgraphic {unnumberedbullet}
    fill basicShape scaled OverlayWidth shifted (0, 0.5*LineHeight)
       withcolor \MPcolor{darkred};
   setbounds currentpicture to OverlayBox;
   \stopuseMPgraphic

   \startuseMPgraphic {numberedbullet}
     fill basicShape xyscaled (0.9*DefaultLineHeight,         0.9*DefaultLineHeight)
    shifted (-0.5(0.9*DefaultLineHeight - OverlayWidth, 0))
       withcolor \MPcolor{abrar};
     setbounds currentpicture to OverlayBox;
     \stopuseMPgraphic

     \defineoverlay[unnumberedbullet][\useMPgraphic{unnumberedbullet}] 
     \defineframed [unnumberedbullet]
          [
            frame=off,
            width=0.5\bodyfontsize,
            background=unnumberedbullet,
            location=low,
          ]

     \definesymbol[unnumberedbullet]
         [{\unnumberedbullet{}}]


     \defineoverlay[numberedbullet][\useMPgraphic{numberedbullet}]
     \defineframed [numberedbullet]
          [
            frame=off,
            width=\lineheight,
            background=numberedbullet,
            foregroundcolor=white,
             % Center the number against capital letters, ignoring  character descent
            location=depth,
            foregroundstyle={\small\small}, % better to define a custom fontswitch
          ]


      \definesymbol[numberedbullet]
         [{\numberedbullet{\currentitemnumber}}]
       \defineframedtext[cadrevert]
     [background=screen,backgroundscreen=.85,
      width=0.9\textwidth,
     frame=off,
     leftframe=on,
     framecolor=darkred,
     rulethickness=3pt]
     \usemodule[symb-imp-fontawesome]
     \usesymbols[fontawesome]
     \setupbodyfont[10pt]
                    %%%%%
     \starttext
     \startalignment[middle]
     \dontleavehmode
     \framed
     [background=color,backgroundcolor=darkred,
     backgroundoffset=5pt,corner=0,frame=0,
     foreground=color,foregroundcolor=white]
     {\ssc \bf RAPPORT MÉDICAL}
     \stopalignment
     \blank[3*big]

    \startitemize[unnumberedbullet,columns,two,stretch]
    \startitem { \bf \ss Nom \& prénoms\hspace[medium]} {\sc Hamid Bougherara} \stopitem
    \startitem {\bf \ss Date de naissance \hspace[medium]} 17/02/2000          \stopitem
    \startitem {\bf\ss Adresse \hspace[medium]} { Aïn Témouchent}   \stopitem
    \startitem {\bf\ss Médecin réferent\hspace[big]} {\sc Dr Hamid}     \stopitem
     %\raggedleft 
      \startitem {\bf\ss Motifs \hspace[big]} angine de poitrine\\
       dyspnée
       \stopitem
     \startitem {\ss\bf Date \hspace[big]} \currentdate \stopitem
     \stopitemize
     \subject{ANTÉCÉDENTS - FDR}
     \startitemize[unnumberedbullet]
     \startitem {\bf \ss Diabète:} bien équilibré sous traitement {\abrar  Glucophage 850mg} \stopitem
     \startitem {\bf \ss HTA:} bien équilibré sous traitement Triatec     \stopitem
     \stopitemize
     \startcadrevert
     Au total il s'agit de Mr {\sc Hamid Bougherara} aux antécedents de     {\bf angine de poitrine} dont le test d'ischémie est revenu positif pour     les territoires \abrar postérieurs.
   \stopcadrevert
    \subject{Dispositions complémentaires}


 \stoptext

正如你所看到的,我在这个草稿中遇到了一些技巧。希望这对你有帮助

编辑

这是一个较少又快又脏例如,使用制表环境和 fontAwesome 符号的页眉(bidi)和页脚。

\setuppapersize[A4]
 \mainlanguage[fr]
%\usemodule[chart]
\setuplayout[header=3.5cm,headerdistance=1cm,margin=2.5cm,footer=2.5cm]
\usesymbols[fontawesome]
\setuppagenumbering[alternative=doublesided,location=]
\definecolor[abrar][r=0.02,g=0.49,b=0.52]
\definefontfeature[default][default][onum=yes]

\definefontfamily[merry][serif][merriweather]
\definefontfamily[merry][sans] [merriweathersans]
\definefontfamily[merry][mono] [TeX Gyre Cursor][features=none]
\definefontfamily[merry][math] [TeX Gyre Pagella Math]


\definelayer[mybg]  % name of the layer
 [x=0mm, y=0mm, % from upper left corner of paper
  width=\paperwidth, height=\paperheight, % let the layer cover the full  paper
   ]

 \setupbackgrounds[page][background=mybg]
 \setupdirections[bidi=global]
 \definefontfeature
  [arabic]
  [mode=node,language=dflt,script=arab,
   init=yes,medi=yes,fina=yes,isol=yes,
   liga=yes,dlig=yes,rlig=yes,clig=yes,
   mark=yes,mkmk=yes,kern=yes,curs=yes,
    saed=yes]

 \starttypescript [serif] [arabic]
  \definefontsynonym [Arabic-Regular] [mothanna] [features=arabic]
  \stoptypescript

 \starttypescript [serif] [arabic] [name]
 \definefontsynonym [Serif]     [Arabic-Regular] [features=arabic]
 \stoptypescript

 \starttypescript [mothanna]
 \definetypeface [mothanna] [rm] [serif] [arabic] [default]
 \stoptypescript

 \usetypescriptfile[type-mothanna]
 \usetypescript[mothanna]
%\pagedir TRT \bodydir TRT \pardir TRT \textdir TRT
 \setupbodyfont[merry,10pt]

 \setuphead[subject][color=abrar,style=\ssa\bf] 
 \setuphead[subsubject][color=abrar, style=\ss\tfb\bi]
 \edef\defaultlineheight{\the\lineheight}
 \startMPdefinitions
   newpath basicShape;
    basicShape := unitsquare ;

  DefaultLineHeight := \defaultlineheight;
 \stopMPdefinitions

 \startuseMPgraphic {unnumberedbullet}
 fill basicShape scaled OverlayWidth shifted (0, 0.5*LineHeight)
   withcolor \MPcolor{darkred};
  setbounds currentpicture to OverlayBox;
 \stopuseMPgraphic

  \startuseMPgraphic {numberedbullet}
   fill basicShape xyscaled (0.9*DefaultLineHeight,   0.9*DefaultLineHeight)
   shifted (-0.5(0.9*DefaultLineHeight - OverlayWidth, 0))
       withcolor \MPcolor{abrar};
    setbounds currentpicture to OverlayBox;
   \stopuseMPgraphic

  \defineoverlay[unnumberedbullet][\useMPgraphic{unnumberedbullet}]
  \defineframed [unnumberedbullet]
          [
            frame=off,
            width=0.5\bodyfontsize,
            background=unnumberedbullet,
            location=low,
          ]

  \definesymbol[unnumberedbullet]
         [{\unnumberedbullet{}}]


 \defineoverlay[numberedbullet][\useMPgraphic{numberedbullet}]
 \defineframed [numberedbullet]
          [
            frame=off,
            width=\lineheight,
            background=numberedbullet,
            foregroundcolor=white,
            % Center the number against capital letters, ignoring character descent
            location=depth,
            foregroundstyle={\small\small}, % better to define a custom fontswitch
          ]


 \definesymbol[numberedbullet]
         [{\numberedbullet{\currentitemnumber}}]
  \defineframedtext[cadrevert]
  [background=screen,backgroundscreen=.85,
   width=0.9\textwidth,
  frame=off,
  leftframe=on,
  framecolor=darkcyan,
  rulethickness=3pt]

  \setupheadertexts[\setups{tableheader}]

 \startsetups tableheader
 \starttabulate[|p|lrw(2cm)|pr|]
 \NC \ss Clinique médico chirurgicale El Abrar\NC          \externalfigure[logo.png][width=2cm, location=inline]\NC \setupalign[r2l]     \switchtobodyfont[mothanna]{ العيادة الطبية الجراحية الأبرار}\NC \NR
   \NC \setupalign[l2r]\ss Service de cardiologie\NC \NC  \setupalign[r2l] \switchtobodyfont[mothanna]{ مصلحة أمراض القلب}\NC\NR
  \setupalign[l2r]
   \NC \ss\tfx Dr Yahyaoui .M.K \NC  \NC \ss\tfx  kaddourkardio(at)gmail.com \NC \NR
  \stoptabulate      
  \stopsetups
  \setuppagenumbering[location={header,margin}]
 \setupfootertexts[\setups{tablefooter}]

  \startsetups tablefooter 
  \startframed[frame=off,
    background=color,
    backgroundcolor=lightgray,
    style={\ss\tfx}]
    \starttabulate[|lw(.5cm)|p|rw(1cm)|p|]
   \NC \symbol[fontawesome][ambulance] \NC 15,rue Tolozane Les palmiers,  Oran \NC \symbol[fontawesome][phone] \NC (+213) 041-496-066 \NC\NR
   \NC \symbol[fontawesome][fax] \NC(+213) 041-233-491 
   \NC \symbol[fontawesome][mobile] \NC (+213) 0561 882-066\NC\NR
   \NC \symbol[fontawesome][envelope-o] \NC clinique-elabrar\symbol[fontawesome][at]laposte.net\NC \symbol[fontawesome][mobile]    \NC (+213) 0561 882-066\NC\NR
 \stoptabulate
 \stopframed
 \stopsetups

  \starttext
  \startalignment[middle]
  \blank[big]
   \dontleavehmode
  \framed
   [background=color,backgroundcolor=darkred,
    backgroundoffset=5pt,corner=0,frame=0,
    foreground=color,foregroundcolor=white]
    {\ssc \bf RAPPORT MÉDICAL}
   \stopalignment
    \blank[2*big]
    \startitemize[unnumberedbullet,columns,two,stretch]
   \startitem { \bf \ss Nom \& prénoms\hspace[medium]} {\sc Hamid Bougherara} \stopitem
   \startitem {\bf \ss Date de naissance \hspace[medium]} 17/02/2000     \stopitem
   \startitem {\bf\ss Adresse \hspace[medium]} { Aïn Témouchent}     \stopitem
   \startitem {\bf\ss Médecin réferent\hspace[big]} {\sc Dr Hamid}     \stopitem
    %\raggedleft 
   \startitem {\bf\ss Motifs \hspace[big]} angine de poitrine\\
   \stopitem
   \startitem {\ss\bf Date \hspace[big]} \currentdate \stopitem
   \stopitemize
   \subject{ANTÉCÉDENTS - FDR}
  \startitemize[unnumberedbullet]
   \startitem {\bf \ss Diabète:} bien équilibré sous traitement {\abrar    Glucophage 850mg} \stopitem
   \startitem {\bf \ss HTA:} bien équilibré sous traitement Triatec     \stopitem
  \stopitemize
  \subject{Dispositions complémentaires}

  Au total il s'agit de Mr {\sc Hamid Bougherara} aux antécedents de     {\bf angine de poitrine} dont le test d'ischémie est revenu positif pour les    territoires {\abrar postérieurs}.


  \stoptext

相关内容