En pocas palabras
Un cuaderno legislativo breve. Muestra la redacción antigua de unos artículos con las palabras suprimidas tachadas y las nuevas subrayadas, y después el artículo entero ya reformado en un recuadro gris.
Lo que vas a componer
Un cuaderno de texto comparado como los que preparan los servicios de las Cámaras: cinco páginas con las tres reformas de la Constitución Española publicadas en el BOE, la del artículo 13.2 en 1992, la del 135 en 2011 y la del 49 en 2024. Cada ley de reforma copia el artículo nuevo entero y no dice qué cambia; aquí la redacción de 1978 y la vigente van en un solo texto, con lo suprimido tachado y lo añadido subrayado, bajo una clave que explica la convención. Al final, el artículo 135 vigente se lee en un recuadro tintado, cada número de apartado en el borde y su texto colgado. La edición inglesa hace lo mismo con la ley estadounidense de 1998 que alargó veinte años los plazos del derecho de autor.
Esta receta responde a
- ¿Cómo muestro una modificación con las palabras suprimidas tachadas y las añadidas subrayadas?
La respuesta corta
// In the text, ~~fifty~~ strikes a deleted word and :underline[70] underlines the new one.
// Both lines are painted from the face's own metrics and take no room, so the struck and
// the inserted words justify and hyphenate like any others. The amended text then sits in
// a box whose paragraphs hang: '(a)', a tab, and every turnover line under the text.
const label = { fontFamily: SANS, fontSize: pt(7.5), fontWeight: 700, letterSpacing: pt(1.1),
textTransform: 'uppercase', color: col('accent') };
const clauses = { fontFamily: SERIF, fontSize: pt(9.5), lineHeight: pt(13), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), textAlign: 'left', // a box's measure is short
hangingIndent: HANG, // every line but the first starts 7 mm in (postext ≥ 1.71)
tabStops: [{ position: HANG }] }; // and the tab after the marker takes the text there
const pad = (v, h) => ({ top: mm(v), right: mm(h), bottom: mm(v), left: mm(h) });
const calloutStyles = [
// The coding legend: a red rule down its side, the label face.
{ id: 'legend', backgroundEnabled: false,
stripe: { enabled: true, side: 'left', width: pt(2.5), color: col('accent') },
padding: pad(1.5, 3.5), body: { fontFamily: SANS, fontSize: pt(9), lineHeight: pt(12.5),
color: col('ink'), boldColor: col('accent'), firstLineIndent: pt(0), textAlign: 'left' } },
// The bill's own words: a red rule on top, clauses hung, no tint.
{ id: 'bill', backgroundEnabled: false,
stripe: { enabled: true, side: 'top', width: pt(2.5), color: col('accent') },
padding: pad(2.5, 0), body: clauses, keepTogether: false, // it may run on to the next page
// its title keeps its case: "(b)" stays "(b)"
titleStyle: { ...label, textTransform: 'none', letterSpacing: pt(0.2), fontSize: pt(8.5),
color: col('ink') } },
// The text as amended: a tint, the clauses hung the same way.
{ id: 'amended', background: col('tint'), padding: pad(3.5, 4.5), titleStyle: label,
body: clauses },
];
Ingredientes
- Funciones
- TachadoSubrayadoPárrafos con sangría francesa en un recuadroTabuladores y rellenosRecuadrosRecuadros que se parten o noPaleta de color semánticaAperturas diseñadasAtributos de títuloCabeceras y foliosCabeceras según el tipo de páginaMárgenes simétricosEstilos de párrafoViudas, huérfanas y líneas cortasExportación a PDFFuentes incrustadas en el PDF
- Tipografía
- Source Serif 4, Source Sans 3 (SIL OFL 1.1)
- Recursos
- Ninguno: todas las imágenes se dibujan en código
Elaboración
#1 · El cambio se marca donde ocurre
El código es la respuesta corta de arriba. Las marcas están en el Markdown: ~~El Gobierno habrá~~ :underline[El Estado y las Comunidades Autónomas habrán] tacha lo antiguo y subraya lo nuevo (tachado, subrayado). Ninguna de las dos líneas ocupa sitio, así que el artículo 49 de 1978, tachado entero en la página 3, se justifica y se divide como el texto que lo rodea. Cada línea sale de las medidas de tachado y subrayado de la propia fuente, en el color de las palabras.
#2 · Los apartados cuelgan dentro del recuadro
body.hangingIndent en un estilo de recuadro cuelga todos sus párrafos (tipografía dentro de un recuadro): la primera línea empieza en el borde interior y las siguientes 7 mm más adentro. Un tabulador a esos mismos 7 mm lleva el texto que sigue al número hasta ese borde, sea cual sea el ancho del número, así que en el Markdown escribes 1.:tab Todas las Administraciones…. Los párrafos sin número de un apartado empiezan por :tab y quedan alineados con el texto colgado. Los dos recuadros comparten la tipografía y solo cambia el marco: un filete rojo sobre el texto de la ley de reforma, una tinta detrás del texto vigente.
#3 · Una banda para la apertura
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const BAND = 66; // mm from the trim top to the foot of the band
const opener = { enabled: true, minHeight: mm(BAND - 22 + 6), marginBottom: pt(0), slot: {
elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('band') },
placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: mm(BAND + 3) } } },
{ kind: 'text', id: 'kicker', content: '{attr.kicker}', ...label, color: col('pale'),
placement: { ...at('container', 'top-left', 0, 6), size: { width: mm(112) } } },
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: SERIF, fontWeight: 700,
fontSize: pt(30), lineHeight: 1.05, color: col('paper'), align: 'left',
placement: { ...at('#kicker', 'below', 0, 3), size: { width: mm(112), height: 'auto' } } },
{ kind: 'text', id: 'dek', content: '{attr.dek}', fontFamily: SERIF, italic: true,
fontSize: pt(10.5), lineHeight: 1.3, color: col('pale'), align: 'left',
placement: { ...at('#title', 'below', 0, 3.5), size: { width: mm(104), height: 'auto' } } },
] } };
La banda azul marino sale a sangre por arriba y por los lados, y el antetítulo y la entradilla vienen de atributos en la línea del título (atributos de título). minHeight fija dónde empieza la clave, unos milímetros bajo la banda.
#4 · Cabeceras según la paridad
const head = (id, content, parity, edge, x, extra = {}) => ({
kind: 'text', id, content, parity, pages: 'body', fontFamily: SANS, fontSize: pt(7.5),
fontWeight: 600, letterSpacing: pt(1.1), textTransform: 'uppercase', color: col('muted'),
placement: { anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(13) } }, ...extra });
const folio = { fontWeight: 700, color: col('ink') };
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-left', OUTER, folio),
head('verso-title', '{title}', 'even', 'top-left', OUTER + 8),
head('recto-title', '{firstMark.h2}', 'odd', 'top-right', -(OUTER + 8)),
head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUTER, folio),
] };
const footer = { elements: [head('drop-folio', '{pageNumber}', 'all', 'top', 0,
{ ...folio, pages: 'opener', placement: at('container', 'top', 0, 9) })] };
La página par lleva el título del cuaderno y la impar la parte en la que se abre, leída del primer título de segundo nivel de la página. pages: 'body' las deja fuera de la apertura, que lleva un folio al pie.
La receta completa
// ═══ Postext Cookbook · Nº 182 · An amendment shown struck through and underlined ═════
// https://postext.dev/en/cookbook/amendment-redline
// Code: MIT · Text: Pub. L. 105-298 and 17 U.S.C. (US Gov., PD); Constitución Española (BOE)
// Fonts: Source Serif 4, Source Sans 3 (SIL OFL 1.1) · Needs postext ≥ 1.73.0
// A comparative print: the law as it stood, each deletion ~~struck through~~ and each
// insertion :underline[underlined], then the amended text in a box whose clauses hang.
import { buildDocumentWithFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'es'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'amendment-redline';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a government-print navy, one red for rules and labels
const palette = {
ink: '#1b1d22', // text: a cool near-black
band: '#1f2b47', // the opener's band: navy
accent: '#a1321f', // labels, stripes, the legend's rule
tint: '#eef0f4', // the box of the amended text
rule: '#c7ccd6', // hairlines
muted: '#5d6370', // running heads, notes, colophon
paper: '#ffffff',
pale: '#c9d2e6', // the kicker and the standfirst on the band
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
{ id: 'main-color', name: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];
// #endregion
const SERIF = 'Source Serif 4', SANS = 'Source Sans 3';
const TRIM = [152, 229], INNER = 20, OUTER = 17; // mm: a 6 × 9 in committee print
const LEAD = 14; // pt: the body leading
const HANG = mm(7); // how far the clauses of a box hang: the width of "(a)" and a space
// #region answer: the marks live in the Markdown; the boxes hang their clauses
// In the text, ~~fifty~~ strikes a deleted word and :underline[70] underlines the new one.
// Both lines are painted from the face's own metrics and take no room, so the struck and
// the inserted words justify and hyphenate like any others. The amended text then sits in
// a box whose paragraphs hang: '(a)', a tab, and every turnover line under the text.
const label = { fontFamily: SANS, fontSize: pt(7.5), fontWeight: 700, letterSpacing: pt(1.1),
textTransform: 'uppercase', color: col('accent') };
const clauses = { fontFamily: SERIF, fontSize: pt(9.5), lineHeight: pt(13), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), textAlign: 'left', // a box's measure is short
hangingIndent: HANG, // every line but the first starts 7 mm in (postext ≥ 1.71)
tabStops: [{ position: HANG }] }; // and the tab after the marker takes the text there
const pad = (v, h) => ({ top: mm(v), right: mm(h), bottom: mm(v), left: mm(h) });
const calloutStyles = [
El script.js compuesto funciona tal cual: pégalo como script de módulo en cualquier página o abre la receta en CodePen. Carpeta de la receta en GitHub ↗ (se abre en una nueva pestaña)
Variantes
#Escribe lo añadido como ++texto++
Con plusUnderline activado, ++y pasivo++ subraya igual que :underline[y pasivo], la grafía que Pandoc y markdown-it usan para el texto insertado.
textAlign: 'justify', firstLineIndent: mm(4.5), indentAfterHeading: false,
+ plusUnderline: true, // ++texto++ subraya; C++ en el texto se escribe entonces C\+\+#Mantén entero el recuadro de la ley de reforma
Sin keepTogether: false el recuadro pasa entero a la página siguiente cuando no cabe, y la página anterior acaba en la línea que lo presenta.
- padding: pad(2.5, 0), body: clauses, keepTogether: false, // it may run on to the next page
+ padding: pad(2.5, 0), body: clauses,Errores frecuentes
- Un párrafo que empieza por un número y un punto (
2. Solamente…) se lee como un elemento de lista, y una barra invertida delante del punto se imprime. Esta edición pone un unidor de palabras (U+2060) entre la cifra y el punto en el texto corrido, y en el recuadro escribe el tabulador justo detrás del punto,1.:tab, que no abre ninguna lista. - El color solo no sobrevive a una fotocopia, que es como suelen circular estos cuadernos; el tachado y el subrayado se leen en blanco y negro, y por eso los eligieron los redactores.
Créditos
- Receta
- Ignacio Ferro
- Texto
- La sección 102 de la Sonny Bono Copyright Term Extension Act (Pub. L. 105-298, 112 Stat. 2827, 1998) y las secciones 302 a 304 del título 17 del United States Code vigentes en 1997 · United States Congress · dominio público
- Los artículos 13.2, 49 y 135 de la Constitución Española en su redacción de 1978 y las reformas de 1992, 2011 y 2024 (textos oficiales, excluidos de la propiedad intelectual por el art. 13 LPI) · Cortes Generales, Boletín Oficial del Estado · dominio público
- Las notas del editor, las claves y los colofones · Ignacio Ferro · CC BY 4.0
- Fuentes
- Source Serif 4 (SIL OFL 1.1) · Source Sans 3 (SIL OFL 1.1)
- Código
- MIT, como Postext
Editar este texto ↗ (se abre en una nueva pestaña)Carpeta de la receta en GitHub ↗ (se abre en una nueva pestaña)


