---
title: "BibTeX"
description: "A citation block with a copy button: the authored BibTeX shown as BibTeX (normalized, aligned, highlighted) or as an APA, MLA, Chicago, Harvard or IEEE reference - one entry or a whole reference list, in a window, minimal or inline."
slug: "bibtex"
---

import { DocPage, PageHeader, SkillPanel, SourceFiles, StatesSection, DocLink, SkillField, SkillText, SkillRow, ApiPill, ApiSection } from "../../lib/components/index";

<DocPage meta={meta}>

<PageHeader slug="bibtex" title="BibTeX" component="bibtex">
  How to cite this: the BibTeX you author, shown the way the reader needs it - as BibTeX (normalized, the fields aligned, highlighted) or formatted as an APA, MLA, Chicago, Harvard or IEEE reference. Several entries become a reference list, sorted or numbered as the style wants. DOIs and URLs are clickable links; the copy button copies exactly what is shown - as plain text, never markup - and says so. Without JavaScript the source stays readable as-is. Used by the <DocLink href="paper.html">Modern Paper</DocLink> template.
</PageHeader>

<SkillPanel component="bibtex">
  <SkillField label="Native basis">
<SkillText>A <code>&lt;figure&gt;</code> (or a <code>&lt;span&gt;</code> inline) around the authored source in <code>&lt;code class="bibtex-source"&gt;</code>. The runtime parses it and adds the bar - format tabs (<code>role="tablist"</code>) and the copy <code>&lt;button&gt;</code> - and the view; a <code>role="status"</code> region announces the copy.</SkillText>
  </SkillField>

  <SkillField label="Web Platform APIs">
<SkillRow>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText" title="the copy - falls back to selecting the view"><code>Clipboard API</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/API/Selection/selectAllChildren" title="the fallback when the clipboard refuses"><code>Selection</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/API/String/normalize" title="LaTeX accents become real characters"><code>String.normalize()</code></ApiPill>
    <ApiPill href="https://www.w3.org/WAI/ARIA/apg/patterns/tabs/" title="the format tabs"><code>APG Tabs</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/text-indent" title="hanging indent for reference lists"><code>text-indent</code></ApiPill>
  </SkillRow>
  </SkillField>

  <SkillField label="Classes">
<SkillRow>
    <code>.bibtex</code>
    <code>.bibtex-source</code>
    <code>.bibtex-bar</code>
    <code>.bibtex-tabs</code>
    <code>.bibtex-tab</code>
    <code>.bibtex-copy</code>
    <code>.bibtex-view</code>
    <code>.bibtex-code</code>
    <code>.bibtex-ref</code>
    <code>.bibtex-list</code>
  </SkillRow>
  </SkillField>

  <SkillField label="Data attributes">
<SkillText><code>data-formats</code> (the tabs: <code>bibtex apa mla chicago harvard ieee</code>), <code>data-format</code> (the first shown), <code>data-variant="minimal|inline"</code>, <code>data-size="sm"</code>, <code>data-align="none"</code>, <code>data-highlight="none"</code>, <code>data-copy="none"</code>.</SkillText>
  </SkillField>

  <SkillField label="Print">
<SkillText>Paper has no tabs to switch and nothing to copy: printed, the bar goes and the block shows the one format it is set to (<code>data-format</code>, else the first of <code>data-formats</code>), its frame closed on every page a long list runs over. A long BibTeX field scrolls sideways on screen and wraps in print.</SkillText>
  </SkillField>
</SkillPanel>

## Formats

```html example label="Six formats, one source" sandbox="links" hint="The authored BibTeX is parsed once; the tabs show it as BibTeX (normalized, aligned, highlighted) or as an APA, MLA, Chicago, Harvard or IEEE reference. DOIs and URLs are links (a new tab); Copy takes exactly what is shown, as plain text. ← / → move between the tabs." previewStyle="align-items:stretch;"
<figure class="bibtex" id="cite-report" data-state-demo aria-label="Cite this report">
  <figcaption>Cite this report</figcaption>
  <pre><code class="bibtex-source">@techreport{homberg2026vae,
  title = {Verified Agentic Engineering: How a deterministic verifier lets coding agents grow a UI system},
  author = {Homberg, Aron},
  institution = {defuss},
  year = {2026},
  month = oct,
  url = {https://github.com/kyr0/defuss-vae}
}</code></pre>
</figure>
```

## Reference list

```html example label="Several entries become a reference list" sandbox="links" hint="IEEE numbers the entries in source order; APA and Chicago sort them by author and year and hang the indent. data-formats picks the tabs and their order, data-format the one that shows first." previewStyle="align-items:stretch;"
<figure class="bibtex" id="cite-list" data-formats="ieee apa chicago bibtex" data-format="ieee" aria-label="References">
  <figcaption>References</figcaption>
  <pre><code class="bibtex-source">@inproceedings{vaswani2017attention,
  author = {Ashish Vaswani and Noam Shazeer and Niki Parmar and Jakob Uszkoreit and Llion Jones and Aidan N. Gomez and {\L}ukasz Kaiser and Illia Polosukhin},
  title = {Attention Is All You Need},
  booktitle = {Advances in Neural Information Processing Systems},
  volume = {30},
  pages = {5998--6008},
  year = {2017},
  publisher = {Curran Associates, Inc.}
}

@article{knuth1984literate,
  author = {Knuth, Donald E.},
  title = {Literate Programming},
  journal = {The Computer Journal},
  volume = {27},
  number = {2},
  pages = {97--111},
  year = {1984},
  doi = {10.1093/comjnl/27.2.97}
}

@book{knuth1984texbook,
  author = {Donald E. Knuth},
  title = {The {\TeX}book},
  publisher = {Addison-Wesley},
  address = {Reading, MA},
  year = {1984}
}</code></pre>
</figure>
```

## Minimal

```html example label="Minimal - one format, a floating copy button" sandbox="links" hint="data-variant=&quot;minimal&quot;: no bar; the copy button floats in the corner while the block is hovered or focused (always on touch screens)." previewStyle="align-items:stretch;"
<figure
  class="bibtex"
  id="cite-minimal"
  data-variant="minimal"
  data-formats="apa"
  aria-label="Literate Programming, APA"
>
  <pre><code class="bibtex-source">@article{knuth1984literate,
  author = {Knuth, Donald E.},
  title = {Literate Programming},
  journal = {The Computer Journal},
  volume = {27},
  number = {2},
  pages = {97--111},
  year = {1984},
  doi = {10.1093/comjnl/27.2.97}
}</code></pre>
</figure>
```

## Rendering options

```html example label="Small, plain BibTeX, no copy button" sandbox="links" hint="data-size=&quot;sm&quot; for dense pages, data-align=&quot;none&quot; keeps the fields unaligned, data-highlight=&quot;none&quot; drops the colors, data-copy=&quot;none&quot; removes the copy button." previewStyle="align-items:stretch;"
<figure
  class="bibtex"
  id="cite-plain"
  data-size="sm"
  data-formats="bibtex harvard"
  data-align="none"
  data-highlight="none"
  data-copy="none"
  aria-label="The TeXbook"
>
  <pre><code class="bibtex-source">@book{knuth1984texbook,
  author = {Donald E. Knuth},
  title = {The {\TeX}book},
  publisher = {Addison-Wesley},
  address = {Reading, MA},
  year = {1984}
}</code></pre>
</figure>
```

## Inline

```html example label="Inline - a reference inside running text" sandbox="links" hint="data-variant=&quot;inline&quot; on a <span>: the formatted reference flows with the sentence, a small copy icon follows it." previewStyle="align-items:stretch;"
<p style="max-width: 40rem; margin: 0; line-height: 1.7"
  >The idea of writing programs as literature goes back to
  <span class="bibtex" id="cite-inline" data-variant="inline" data-formats="mla"
    ><code class="bibtex-source"
      >@article{knuth1984literate, author = {Knuth, Donald E.}, title = {Literate Programming}, journal = {The Computer
      Journal}, volume = {27}, number = {2}, pages = {97--111}, year = {1984}, doi = {10.1093/comjnl/27.2.97} }</code
    ></span
  >
  - and it shaped how documentation tools work today.</p
>
```

## From script

```html example label="Driven from outside" sandbox="links" hint="df$.shadcn.bibtex.show(el, format) switches the format, .copy(el) copies, .format(text, style) formats without an element; bibtex-format and bibtex-copy report every change." previewStyle="align-items:stretch;"
<div class="grid gap-3" style="max-width: 44rem">
  <div class="flex flex-wrap gap-2">
    <button class="btn" data-size="sm" data-variant="outline" id="cite-js-apa">Show APA</button>
    <button class="btn" data-size="sm" data-variant="outline" id="cite-js-ieee">Show IEEE</button>
    <button class="btn" data-size="sm" id="cite-js-copy">Copy</button>
  </div>
  <figure class="bibtex" id="cite-js" data-formats="bibtex apa ieee" aria-label="Attention Is All You Need">
    <pre><code class="bibtex-source">@inproceedings{vaswani2017attention,
  author = {Ashish Vaswani and Noam Shazeer and Niki Parmar and Jakob Uszkoreit and Llion Jones and Aidan N. Gomez and {\L}ukasz Kaiser and Illia Polosukhin},
  title = {Attention Is All You Need},
  booktitle = {Advances in Neural Information Processing Systems},
  volume = {30},
  pages = {5998--6008},
  year = {2017},
  publisher = {Curran Associates, Inc.}
}</code></pre>
  </figure>
  <output id="cite-js-log" class="text-sm text-muted-foreground">Events show up here.</output>
</div>
<script>
  document.addEventListener('DOMContentLoaded', () => {
    const lib = df$.shadcn.bibtex;
    const el = document.getElementById('cite-js');
    const log = document.getElementById('cite-js-log');
    document.getElementById('cite-js-apa').addEventListener('click', () => lib.show(el, 'apa'));
    document.getElementById('cite-js-ieee').addEventListener('click', () => lib.show(el, 'ieee'));
    document.getElementById('cite-js-copy').addEventListener('click', () => lib.copy(el));
    el.addEventListener('bibtex-format', (e) => {
      log.textContent = 'bibtex-format: ' + e.detail.format;
    });
    el.addEventListener('bibtex-copy', (e) => {
      log.textContent =
        'bibtex-copy: ' +
        e.detail.format +
        (e.detail.ok ? ' - ' + e.detail.text.length + ' characters' : ' - selected for a manual copy');
    });
  });
</script>
```

## Print

```html example label="Printed: the chosen format, no bar" mode="print" sandbox="links" hint="The preview boots in the Print device, whose print styles apply: no tabs, no copy button - each block prints the format it is set to. The citation is BibTeX (the first of data-formats), the reference list APA (data-format). Choose the printed format with data-format; switch the preview to Full for the tabs." previewStyle="align-items:stretch;"
<figure class="bibtex" id="print-cite" data-formats="bibtex apa ieee" aria-label="Cite this note">
  <figcaption>Cite this note</figcaption>
  <pre><code class="bibtex-source">@techreport{claude2026printing,
  title = {Printing a Paper: Profiles, Breaks and What Stays on Screen},
  author = {Claude and Homberg, Aron},
  institution = {defuss},
  year = {2026},
  month = oct,
  url = {https://shadcn.defuss.org/papers/paper.html}
}</code></pre>
</figure>
<figure class="bibtex" id="print-refs" data-formats="apa ieee bibtex" data-format="apa" aria-label="References">
  <figcaption>References</figcaption>
  <pre><code class="bibtex-source">@article{knuth1984literate,
  author = {Knuth, Donald E.},
  title = {Literate Programming},
  journal = {The Computer Journal},
  volume = {27},
  number = {2},
  pages = {97--111},
  year = {1984},
  doi = {10.1093/comjnl/27.2.97}
}

@book{knuth1984texbook,
  author = {Donald E. Knuth},
  title = {The {\TeX}book},
  publisher = {Addison-Wesley},
  address = {Reading, MA},
  year = {1984}
}</code></pre>
</figure>
```

<StatesSection>
  <p class="text-sm text-muted-foreground m-0 mb-3">Named states via the shared State API, bound on each block:</p>
  <ul class="text-sm text-muted-foreground m-0 mb-3 ps-5">
    <li><code>default</code> - the source in the format of <code>config.format</code> (<code>data-format</code> on the block)</li>
    <li><code>copied</code> - the copy feedback: the button says Copied (<code>data-copied</code>), the status announces it; back to <code>default</code> after two seconds</li>
  </ul>
  <p class="text-sm text-muted-foreground">The config is <code>&#123; format &#125;</code>. The first example carries <code>data-state-demo</code>; <code>bun run screenshots</code> drives it via <code>el.api.setState(name)</code> and captures <code>screenshots/\{mode\}/bibtex-\{state\}.png</code>.</p>

Machine contract - verified against <a class="link" href="../schemas/bibtex.schema.json"><code>bibtex.schema.json</code></a> by <code>bun run verify</code>:

```states
| State | Type | Values | Default | Description |
| --- | --- | --- | --- | --- |
| `format` | `enum` | `bibtex`, `apa`, `mla`, `chicago`, `harvard`, `ieee` | `bibtex` | The format shown - `setState('default', { format: 'apa' })`; mirrored as `data-format` on the block. |
| `copied` | `boolean` | `true`, `false` | `false` | The copy feedback - `setState('copied')`; returns to `default` after two seconds. |
```

</StatesSection>

<ApiSection component="bibtex" />

<SourceFiles component="bibtex" section="css" />

<SourceFiles component="bibtex" section="js" jsTitle="JS" />

</DocPage>
