Em poucas palavras
Um artigo curto para um congresso, em duas colunas. O autor escreve um código para cada fonte; o Postext numera as citações entre colchetes, remete às seções por número e página e imprime no fim a lista numerada de referências.
O que você vai compor
Um artigo de duas páginas para um pequeno workshop de engenharia de documentos, composto como os anais de congressos do IEEE compõem os seus: papel carta US, duas colunas de três polegadas e meia, um tipo no estilo Times em 10 pt e seções numeradas I, II, III em versais centralizadas. O título, os três blocos de autor, o resumo e os termos de indexação ocupam as duas colunas sob uma faixa clara no azul do workshop, a única cor das páginas. Os autores citam com chaves do BibTeX; o Postext imprime [1] na ordem em que cada obra é citada pela primeira vez, agrupa três obras seguidas como [2]–[4], escreve “Knuth and Plass [1]” quando os nomes fazem parte da frase e monta no fim a lista numerada em 8 pt. As remissões a seções imprimem “Section IV, on p. 2” e continuam certas quando o texto se desloca.
Esta receita responde a
- Como cito obras e monto a bibliografia em APA, IEEE ou outro estilo de citação?
- Como remeto a uma seção e à página em que ela está, e mantenho as duas corretas quando o livro muda?
A resposta curta
// [@key] prints [1] in order of first citation, @key in the sentence "Knuth and Plass [1]".
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
// The bundled IEEE style lists [2], [3], [4]; the IEEE editorial guide writes [2]–[4].
// One attribute on the CSL <citation> element makes citeproc-js join the run.
const ieee = STYLES.ieee.replace('<citation>', '<citation collapse="citation-number">');
const citations = {
style: 'custom', customStyle: ieee, // or style: 'ieee' for the file as it ships
link: true,
bibliography: {
fontSize: em(0.8), lineHeight: pt(9.4), // 8 pt on 9.4 pt, two sizes under the text
labelWidth: mm(6), // the [n] column: wide enough for [10], the turnovers align after it
entrySpacing: pt(1.2),
doi: 'text', // printed, not linked: the PDF stays black
},
};
Ingredientes
- Funcionalidades
- Citações em um estilo de citaçãoBibliografia a partir das referênciasReferências cruzadasTítulos numeradosEstilos de títuloCapítulos sem númeroAberturas desenhadasBoxes na largura da páginaPaleta de cores semânticaExportação para PDF
- Também usa
- BoxesCitações que posicionam as figurasAtributos de títuloFontes incorporadas ao PDFQuebras de linha nos títulos
- Tipografia
- STIX Two Text, Schibsted Grotesk (SIL OFL 1.1)
- Materiais
- Nenhum: todas as imagens são desenhadas em código
Preparo
#1 · O estilo IEEE, com seus intervalos
O código é a resposta curta logo acima. Registrado uma vez, o postext-citeproc formata cada [@key] com o citeproc-js e o estilo CSL do IEEE, numerando as obras na ordem em que são citadas pela primeira vez. O arquivo de estilo que acompanha o motor escreve três obras seguidas como [2], [3], [4]; o guia editorial do IEEE as junta como [2]–[4]. Basta acrescentar collapse="citation-number" ao elemento <citation> do estilo e passar o resultado como customStyle para que o citeproc-js faça isso. labelWidth dá aos números da lista uma coluna própria, de modo que a segunda linha de cada entrada começa sob a primeira palavra, e não sob o colchete.
#2 · Um bloco de título sobre as duas colunas
const text = (id, content, size, extra) => ({ kind: 'text', id, content, fontFamily: SERIF,
fontSize: pt(size), color: col('ink'), align: 'center', overflow: 'wrap', ...extra });
const at = (to, edge, x, y, width) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) },
...(width && { size: { width: mm(width), height: 'auto' } }) });
const AUTHOR_W = MEASURE / 3;
const titleBlock = {
enabled: true,
minHeight: mm(64), // venue line, two lines of title and five of author block
slot: { elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('tint') }, // from the trim's top
placement: { anchor: { to: 'page', edge: 'top-left' },
size: { width: 'fill', height: mm(TOP + 66) } } },
text('venue', '{attr.venue}', 7.5, { fontFamily: SANS, fontWeight: 600, color: col('accent'),
letterSpacing: pt(1.2), textTransform: 'uppercase',
placement: at('container', 'top-left', 0, 0, MEASURE) }),
{ kind: 'rule', id: 'venue-rule', thickness: pt(0.5), color: col('rule'),
placement: at('#venue', 'below', 0, 2, MEASURE) },
text('title', '{titleText}', 23, { lineHeight: 1.1, placement: at('#venue', 'below', 0, 7,
MEASURE) }),
...['a1', 'a2', 'a3'].map((id, i) => text(id, `{attr.${id}}`, 9.5, { lineHeight: 1.25,
placement: at('#title', 'below', i * AUTHOR_W, 6, AUTHOR_W) })),
] },
};
O título é o único título de nível 1 do documento, com o estilo paper. O estilo ocupa a largura da página e desenha o título a partir do design: a linha do evento, o título e três blocos de autor com um terço da medida, cada um lido de um atributo do título em que \n quebra as linhas. A faixa é uma caixa ancorada ao refile, por isso chega até a borda superior do papel.
#3 · Resumo e termos de indexação em negrito
const calloutStyles = [{ id: 'abstract', span: 'page', backgroundEnabled: false,
border: { enabled: false }, stripe: { enabled: true, side: 'top', width: pt(0.5),
color: col('rule') },
padding: { top: mm(3), right: mm(14), bottom: mm(1), left: mm(14) },
marginTop: pt(0), marginBottom: pt(LEAD),
body: { fontSize: pt(9), lineHeight: pt(11), fontWeight: 700, firstLineIndent: pt(0),
textAlign: 'justify', paragraphSpacing: true } }];
Um boxe na largura da página leva o resumo e os termos de indexação. O corpo vai em 9 pt negrito, como o IEEE compõe, e ***Abstract*—** no texto dá o rótulo em itálico com seu travessão. O fio fino acima é a tarja do boxe, e o espaçamento interno estreita a medida para cerca de cem caracteres.
#4 · Seções numeradas e remissões a elas
const levels = [
{ level: 1, breakBefore: { enabled: true, parity: 'any' } }, // any page: no forced recto
{ level: 2, numberingTemplate: '{2:I}.', numberSeparator: ' ', fontSize: pt(9),
lineHeight: pt(LEAD), fontWeight: 400, letterSpacing: em(0.06), textTransform: 'uppercase',
marginTop: pt(LEAD), marginBottom: pt(0) }, // a line above, none below: at a column's head
// the margin above drops and the text still starts on the next grid line
];
const headingStyles = [
{ id: 'paper', numbered: false, span: 'page', advancedDesign: titleBlock },
{ id: 'back', numbered: false }, // Acknowledgment and References: no number
];
const crossRefs = { section: t({ en: 'Section {n}', es: 'sección {n}' }) };
{2:I}. numera as seções I., II., III. Uma remissão imprime o número sem o ponto, de modo que :ref{id="sec:results"} dá “Section IV” pelo modelo de crossRefs, e :ref{id="sec:results" style=page} dá “p. 2”. As duas são calculadas sobre as páginas já compostas, e por isso acompanham o texto se um parágrafo for acrescentado ou uma seção mudar de lugar. Os títulos Acknowledgment e References levam o estilo back e ficam sem número.
const palette = {
ink: '#16181d', accent: '#1d4a7a', tint: '#e9eef5', rule: '#aeb6c2', muted: '#5a606b',
paper: '#ffffff',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.accent })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
A receita completa
// ═══ Postext Cookbook · Nº 088 · A two-column conference paper in IEEE style ═══════
// https://postext.dev/en/cookbook/ieee-conference-paper
// Code: MIT · Text: original (CC BY 4.0) · Pictures: none
// Fonts: STIX Two Text, Schibsted Grotesk (SIL OFL 1.1) · Needs postext ≥ 1.65.0
import {
buildDocumentWithFonts, renderPageToCanvas, registerCitationEngine,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
import { createCiteprocEngine, STYLES, LOCALES } from 'https://esm.sh/postext-citeproc';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'ieee-conference-paper';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: black type on white, with one blue for the workshop's own marks
const palette = {
ink: '#16181d', accent: '#1d4a7a', tint: '#e9eef5', rule: '#aeb6c2', muted: '#5a606b',
paper: '#ffffff',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.accent })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const [SERIF, SANS] = ['STIX Two Text', 'Schibsted Grotesk'];
// The IEEE conference template in mm: US letter, 0.75 in head, 1 in foot, 0.625 in sides,
// two columns of 3.5 in with 0.25 in between.
const [TRIM_W, TRIM_H, TOP, BOTTOM, SIDE, GUTTER] = [215.9, 279.4, 19, 25.4, 15.9, 6.35];
const MEASURE = TRIM_W - 2 * SIDE;
const LEAD = 12; // pt: 10 pt type on 12 pt, as the template sets it
// #region answer: IEEE numbers, collapsed ranges and a references list with a label column
// [@key] prints [1] in order of first citation, @key in the sentence "Knuth and Plass [1]".
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
// The bundled IEEE style lists [2], [3], [4]; the IEEE editorial guide writes [2]–[4].
// One attribute on the CSL <citation> element makes citeproc-js join the run.
const ieee = STYLES.ieee.replace('<citation>', '<citation collapse="citation-number">');
const citations = {
style: 'custom', customStyle: ieee, // or style: 'ieee' for the file as it ships
link: true,
bibliography: {
fontSize: em(0.8), lineHeight: pt(9.4), // 8 pt on 9.4 pt, two sizes under the text
labelWidth: mm(6), // the [n] column: wide enough for [10], the turnovers align after it
entrySpacing: pt(1.2),
doi: 'text', // printed, not linked: the PDF stays black
},
};
// #endregion
O script.js montado funciona como está: cole-o como script de módulo em qualquer página ou abra a receita no CodePen. Pasta da receita no GitHub ↗ (abre em uma nova aba)
Variações
#Mantenha o estilo como ele vem
Sem a alteração, três obras seguidas saem uma a uma, como algumas revistas preferem.
- style: 'custom', customStyle: ieee, // or style: 'ieee' for the file as it ships
+ style: 'ieee',#Escreva os intervalos dentro de um só par de colchetes
Alguns estilos numéricos imprimem [2–4]. O marcador brackets escreve os números por conta própria e junta os consecutivos.
- style: 'custom', customStyle: ieee, // or style: 'ieee' for the file as it ships
+ style: 'ieee', marker: 'brackets', collapseRanges: true,Erros comuns
- Quando as duas colunas da última página não terminam na mesma altura, veja o que fica no ponto onde seriam cortadas: o motor não deixa um título de seção no pé de uma coluna, longe do texto, e desiste do corte. Uma frase a mais ou a menos nas últimas seções leva o corte para depois do título.
- Comandos do BibTeX como
{\TeX}não são expandidos. EscrevaThe {TeX}book; as chaves mantêm as maiúsculas como estão.
Créditos
- Receita
- Ignacio Ferro
- Texto
- Texto original, CC BY 4.0
- Fontes
- STIX Two Text (SIL OFL 1.1) · Schibsted Grotesk (SIL OFL 1.1)
- Código
- MIT, como o Postext
Editar este texto ↗ (abre em uma nova aba)Pasta da receita no GitHub ↗ (abre em uma nova aba)


