Citations and a bibliography
A document's sources, the style its citations use, citations and a bibliography, as Word's References > Citations & Bibliography edits them. Each change is one undo step.
using DocWright.Dom.Bibliography;
using DocWright.Dom.Editing;
var source = new BibliographySource("Lov43", BibliographySourceType.Book);
source.Authors.Add(new BibliographyPerson("Lovelace", "Ada", "King"));
source["Title"] = "Notes on the Analytical Engine";
source["Year"] = "1843";
source["City"] = "London";
source["Publisher"] = "Taylor";
document.AddSource(at, source);
document.InsertCitation(at, new CitationRequest { Tag = "Lov43", Pages = "12" }); // (Lovelace, 1843, p. 12)
document.InsertBibliography(DocumentPosition.EndOf(lastParagraph));
document.SetBibliographyStyle(at, BibliographyStyle.Mla); // (Lovelace 12)
- Sources live where Word keeps them: the document's
customXmlsources part, added with its properties part the first time.ReadSourcesreturns them and the style;ChangeSourceandRemoveSourceedit the list (a source a citation names is not removed). - Styles: APA (Sixth Edition, Word's default), MLA (Seventh) and Chicago (Sixteenth), written to read exactly as Word writes them: the text, the bibliography's order and its italics.
- A citation is a CITATION field in a citation content control;
CitationRequestholds Word's switches: pages, volume, a prefix and a suffix, and the author, year or title left out. - The bibliography is a BIBLIOGRAPHY field whose result is a paragraph per source in the Bibliography style.
UpdateFieldsupdates citations and rebuilds bibliographies, as Word's F9 does; a new style or a changed source updates them at once.
CitationFormatter formats citations and entries without a document, for a list of sources of your own.