typst

Repositório typst
git clone git://git.sivaldodavi.com/typst.git
Log | Files | Refs

abnt-base.typ (3213B)


      1 // ============================================================
      2 // MÓDULO BASE ABNT — configurações e estilos compartilhados
      3 // ============================================================
      4 
      5 // ---- Constantes (ajuste aqui se necessário) ------------------
      6 #let fonte-principal = "Liberation Sans"
      7 #let tamanho-corpo   = 12pt
      8 #let tamanho-nota    = 10pt
      9 #let leading-1-5     = 1.5em
     10 #let leading-simples = 1em
     11 #let recuo-paragrafo = 1.25cm
     12 
     13 // ---- Configuração global (texto, página, parágrafo, títulos) ----
     14 #let configurar(numeracao: "1", pagina-inicial: none, corpo) = {
     15   // Fonte e idioma
     16   set text(
     17     font: fonte-principal,
     18     size: tamanho-corpo,
     19     lang: "pt",
     20     region: "BR",
     21     hyphenate: false,
     22   )
     23 
     24   // Página A4 margens ABNT
     25   set page(
     26     paper: "a4",
     27     margin: (top: 3cm, left: 3cm, bottom: 2cm, right: 2cm),
     28     numbering: numeracao,
     29     number-align: top + right,
     30   )
     31 
     32   // Parágrafo: entrelinha 1,5; recuo; justificado
     33   set par(
     34     leading: leading-1-5,
     35     justify: true,
     36     first-line-indent: (amount: recuo-paragrafo, all: true),
     37   )
     38 
     39   // Reinício de contagem de página (se necessário)
     40   if pagina-inicial != none {
     41     counter(page).update(pagina-inicial)
     42   }
     43 
     44   // Numeração progressiva
     45   set heading(numbering: "1.1")
     46 
     47   // Estilo dos títulos — tamanho SEMPRE 12pt
     48   show heading: it => {
     49     let numero = if it.numbering != none {
     50       counter(heading).display(it.numbering) + h(0.5em)
     51     } else { none }
     52 
     53     let conteudo = if it.level == 1 {
     54       text(weight: "bold", size: tamanho-corpo)[#numero#upper(it.body)]
     55     } else if it.level == 2 {
     56       text(weight: "bold", size: tamanho-corpo)[#numero#it.body]
     57     } else {
     58       text(weight: "regular", style: "italic", size: tamanho-corpo)[#numero#it.body]
     59     }
     60 
     61     v(1em)
     62     block(width: 100%)[
     63       #set par(first-line-indent: (amount: 0pt, all: true))
     64       #conteudo
     65     ]
     66     v(1em)
     67   }
     68 
     69   corpo
     70 }
     71 
     72 // ---- Notas de rodapé (10pt, espaçamento simples) -------------
     73 #let configurar-rodape(corpo) = {
     74   show footnote.entry: set text(size: tamanho-nota)
     75   show footnote.entry: set par(
     76     leading: leading-simples,
     77     first-line-indent: (amount: 0pt, all: true),
     78     justify: true,
     79   )
     80   corpo
     81 }
     82 
     83 // ---- Citação direta longa (mais de 3 linhas) ------------------
     84 #let citacao-longa(corpo) = {
     85   v(1em)
     86   block(inset: (left: 4cm))[
     87     #set par(first-line-indent: 0pt, leading: leading-simples, justify: true)
     88     #text(size: tamanho-nota)[#corpo]
     89   ]
     90   v(1em)
     91 }
     92 
     93 // ---- Seção de referências (título centralizado, esp. duplo) ---
     94 #let referencias(conteudo) = {
     95   pagebreak()
     96   align(center)[#text(weight: "bold")[REFERÊNCIAS]]
     97   v(1.5em)
     98 
     99   // Configuração base: alinhamento à esquerda, espaço simples
    100   set par(
    101     first-line-indent: 0pt,
    102     justify: false,
    103     leading: leading-simples,   // 1em
    104   )
    105 
    106   // Força uma linha em branco após cada parágrafo (exceto o último)
    107   show: it => {
    108     it
    109     v(1em)   // blank line de 12pt (equivalente a uma linha simples)
    110   }
    111 
    112   conteudo
    113 }
    114 
    115 // ---- Alíneas no formato a), b), c) ... ------------------------
    116 #let configurar-alineas(corpo) = {
    117   set enum(numbering: "a)", indent: recuo-paragrafo, body-indent: 0.5cm)
    118   corpo
    119 }