[{"data":1,"prerenderedAt":702},["ShallowReactive",2],{"navigation_docs":3,"-programming-creating-package-documentation":351,"-programming-creating-package-documentation-surround":697},[4,31,45,83,109,147,197,215,253,291,329],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":30},"Getting Started","i-lucide-play","\u002Fgetting-started","01.getting-started",[10,14,18,22,26],{"title":11,"path":12,"stem":13},"Introduction","\u002Fgetting-started\u002Fintroduction","01.getting-started\u002F01.introduction",{"title":15,"path":16,"stem":17},"Installation","\u002Fgetting-started\u002Finstallation","01.getting-started\u002F02.installation",{"title":19,"path":20,"stem":21},"Installing Extra Packages","\u002Fgetting-started\u002Finstalling-extra-packages","01.getting-started\u002F03.installing-extra-packages",{"title":23,"path":24,"stem":25},"Basics","\u002Fgetting-started\u002Fbasics","01.getting-started\u002F04.basics",{"title":27,"path":28,"stem":29},"How to Get Help","\u002Fgetting-started\u002Fhow-to-get-help","01.getting-started\u002F05.how-to-get-help",false,{"title":32,"icon":33,"path":34,"stem":35,"children":36,"page":30},"AI Integration","i-lucide-bot","\u002Fai-integration","02.ai-integration",[37,41],{"title":38,"path":39,"stem":40},"Model Context Protocol (MCP)","\u002Fai-integration\u002Fmcp","02.ai-integration\u002F01.mcp",{"title":42,"path":43,"stem":44},"Agent Skills","\u002Fai-integration\u002Fskills","02.ai-integration\u002F02.skills",{"title":46,"icon":47,"path":48,"stem":49,"children":50,"page":30},"Document Fundamentals","i-lucide-file-text","\u002Fdocument-fundamentals","03.document-fundamentals",[51,55,59,63,67,71,75,79],{"title":52,"path":53,"stem":54},"Document Structure","\u002Fdocument-fundamentals\u002Fdocument-structure","03.document-fundamentals\u002F01.document-structure",{"title":56,"path":57,"stem":58},"Text Formatting","\u002Fdocument-fundamentals\u002Ftext-formatting","03.document-fundamentals\u002F02.text-formatting",{"title":60,"path":61,"stem":62},"Paragraph Formatting","\u002Fdocument-fundamentals\u002Fparagraph-formatting","03.document-fundamentals\u002F03.paragraph-formatting",{"title":64,"path":65,"stem":66},"Fonts","\u002Fdocument-fundamentals\u002Ffonts","03.document-fundamentals\u002F04.fonts",{"title":68,"path":69,"stem":70},"Colors","\u002Fdocument-fundamentals\u002Fcolors","03.document-fundamentals\u002F05.colors",{"title":72,"path":73,"stem":74},"List Structures","\u002Fdocument-fundamentals\u002Flist-structures","03.document-fundamentals\u002F06.list-structures",{"title":76,"path":77,"stem":78},"Special Characters","\u002Fdocument-fundamentals\u002Fspecial-characters","03.document-fundamentals\u002F07.special-characters",{"title":80,"path":81,"stem":82},"Internationalization","\u002Fdocument-fundamentals\u002Finternationalization","03.document-fundamentals\u002F08.internationalization",{"title":84,"icon":85,"path":86,"stem":87,"children":88,"page":30},"Page Design","i-lucide-layout","\u002Fpage-design","04.page-design",[89,93,97,101,105],{"title":90,"path":91,"stem":92},"Page Layout","\u002Fpage-design\u002Fpage-layout","04.page-design\u002F01.page-layout",{"title":94,"path":95,"stem":96},"Page Headers and Footers","\u002Fpage-design\u002Fcustomizing-page-headers-and-footers","04.page-design\u002F02.customizing-page-headers-and-footers",{"title":98,"path":99,"stem":100},"Title Creation","\u002Fpage-design\u002Ftitle-creation","04.page-design\u002F03.title-creation",{"title":102,"path":103,"stem":104},"Footnotes and Margin Notes","\u002Fpage-design\u002Ffootnotes-and-margin-notes","04.page-design\u002F04.footnotes-and-margin-notes",{"title":106,"path":107,"stem":108},"Rotations","\u002Fpage-design\u002Frotations","04.page-design\u002F05.rotations",{"title":110,"icon":111,"path":112,"stem":113,"children":114,"page":30},"Tables and Graphics","i-lucide-table","\u002Ftables-and-graphics","05.tables-and-graphics",[115,119,123,127,131,135,139,143],{"title":116,"path":117,"stem":118},"Tables","\u002Ftables-and-graphics\u002Ftables","05.tables-and-graphics\u002F01.tables",{"title":120,"path":121,"stem":122},"Floats, Figures and Captions","\u002Ftables-and-graphics\u002Ffloats-figures-and-captions","05.tables-and-graphics\u002F02.floats-figures-and-captions",{"title":124,"path":125,"stem":126},"Importing Graphics","\u002Ftables-and-graphics\u002Fimporting-graphics","05.tables-and-graphics\u002F03.importing-graphics",{"title":128,"path":129,"stem":130},"Introducing Procedural Graphics","\u002Ftables-and-graphics\u002Fintroducing-procedural-graphics","05.tables-and-graphics\u002F04.introducing-procedural-graphics",{"title":132,"path":133,"stem":134},"PGF\u002FTikZ","\u002Ftables-and-graphics\u002Fpgf-tikz","05.tables-and-graphics\u002F05.pgf-tikz",{"title":136,"path":137,"stem":138},"PSTricks","\u002Ftables-and-graphics\u002Fpstricks","05.tables-and-graphics\u002F06.pstricks",{"title":140,"path":141,"stem":142},"MetaPost","\u002Ftables-and-graphics\u002Fmetapost","05.tables-and-graphics\u002F07.metapost",{"title":144,"path":145,"stem":146},"Picture","\u002Ftables-and-graphics\u002Fpicture","05.tables-and-graphics\u002F08.picture",{"title":148,"icon":149,"path":150,"stem":151,"children":152,"page":30},"Technical Writing","i-lucide-flask-conical","\u002Ftechnical-writing","06.technical-writing",[153,157,161,165,169,173,177,181,185,189,193],{"title":154,"path":155,"stem":156},"Mathematics","\u002Ftechnical-writing\u002Fmathematics","06.technical-writing\u002F01.mathematics",{"title":158,"path":159,"stem":160},"Advanced Mathematics","\u002Ftechnical-writing\u002Fadvanced-mathematics","06.technical-writing\u002F02.advanced-mathematics",{"title":162,"path":163,"stem":164},"Theorems","\u002Ftechnical-writing\u002Ftheorems","06.technical-writing\u002F03.theorems",{"title":166,"path":167,"stem":168},"Algorithms","\u002Ftechnical-writing\u002Falgorithms","06.technical-writing\u002F04.algorithms",{"title":170,"path":171,"stem":172},"Source Code Listings","\u002Ftechnical-writing\u002Fsource-code-listings","06.technical-writing\u002F05.source-code-listings",{"title":174,"path":175,"stem":176},"Chemical Graphics","\u002Ftechnical-writing\u002Fchemical-graphics","06.technical-writing\u002F06.chemical-graphics",{"title":178,"path":179,"stem":180},"Linguistics","\u002Ftechnical-writing\u002Flinguistics","06.technical-writing\u002F07.linguistics",{"title":182,"path":183,"stem":184},"Bibliography Management","\u002Ftechnical-writing\u002Fbibliography-management","06.technical-writing\u002F08.bibliography-management",{"title":186,"path":187,"stem":188},"More Bibliographies","\u002Ftechnical-writing\u002Fmore-bibliographies","06.technical-writing\u002F09.more-bibliographies",{"title":190,"path":191,"stem":192},"Indexing","\u002Ftechnical-writing\u002Findices","06.technical-writing\u002F10.indices",{"title":194,"path":195,"stem":196},"Glossary","\u002Ftechnical-writing\u002Fglossary","06.technical-writing\u002F11.glossary",{"title":198,"icon":199,"path":200,"stem":201,"children":202,"page":30},"Cross-References and Links","i-lucide-link","\u002Fcross-references","07.cross-references",[203,207,211],{"title":204,"path":205,"stem":206},"Labels and Cross Referencing","\u002Fcross-references\u002Flabels-and-cross-referencing","07.cross-references\u002F01.labels-and-cross-referencing",{"title":208,"path":209,"stem":210},"Hyperlinks","\u002Fcross-references\u002Fhyperlinks","07.cross-references\u002F02.hyperlinks",{"title":212,"path":213,"stem":214},"Initials","\u002Fcross-references\u002Finitials","07.cross-references\u002F03.initials",{"title":216,"icon":217,"path":218,"stem":219,"children":220,"page":30},"Specialized Documents","i-lucide-file-badge","\u002Fspecialized-documents","08.specialized-documents",[221,225,229,233,237,241,245,249],{"title":222,"path":223,"stem":224},"Scientific Reports","\u002Fspecialized-documents\u002Fscientific-reports","08.specialized-documents\u002F01.scientific-reports",{"title":226,"path":227,"stem":228},"Letters","\u002Fspecialized-documents\u002Fletters","08.specialized-documents\u002F02.letters",{"title":230,"path":231,"stem":232},"Presentations","\u002Fspecialized-documents\u002Fpresentations","08.specialized-documents\u002F03.presentations",{"title":234,"path":235,"stem":236},"Teacher's Corner","\u002Fspecialized-documents\u002Fteachers-corner","08.specialized-documents\u002F04.teachers-corner",{"title":238,"path":239,"stem":240},"Curriculum Vitae","\u002Fspecialized-documents\u002Fcurriculum-vitae","08.specialized-documents\u002F05.curriculum-vitae",{"title":242,"path":243,"stem":244},"Academic Journals","\u002Fspecialized-documents\u002Facademic-journals","08.specialized-documents\u002F06.academic-journals",{"title":246,"path":247,"stem":248},"Xy-pic","\u002Fspecialized-documents\u002Fxy-pic","08.specialized-documents\u002F07.xy-pic",{"title":250,"path":251,"stem":252},"Creating 3D Graphics","\u002Fspecialized-documents\u002Fcreating-3d-graphics","08.specialized-documents\u002F08.creating-3d-graphics",{"title":254,"icon":255,"path":256,"stem":257,"children":258,"page":30},"Programming LaTeX","i-lucide-code","\u002Fprogramming","09.programming",[259,263,267,271,275,279,283,287],{"title":260,"path":261,"stem":262},"Macros","\u002Fprogramming\u002Fmacros","09.programming\u002F01.macros",{"title":264,"path":265,"stem":266},"Plain TeX","\u002Fprogramming\u002Fplain-tex","09.programming\u002F02.plain-tex",{"title":268,"path":269,"stem":270},"Creating Packages","\u002Fprogramming\u002Fcreating-packages","09.programming\u002F03.creating-packages",{"title":272,"path":273,"stem":274},"Creating Package Documentation","\u002Fprogramming\u002Fcreating-package-documentation","09.programming\u002F04.creating-package-documentation",{"title":276,"path":277,"stem":278},"Themes","\u002Fprogramming\u002Fthemes","09.programming\u002F05.themes",{"title":280,"path":281,"stem":282},"Modular Documents","\u002Fprogramming\u002Fmodular-documents","09.programming\u002F06.modular-documents",{"title":284,"path":285,"stem":286},"Collaborative Writing of LaTeX Documents","\u002Fprogramming\u002Fcollaborative-writing","09.programming\u002F07.collaborative-writing",{"title":288,"path":289,"stem":290},"Export To Other Formats","\u002Fprogramming\u002Fexport-to-other-formats","09.programming\u002F08.export-to-other-formats",{"title":292,"icon":293,"path":294,"stem":295,"children":296,"page":30},"Reference and Help","i-lucide-book-open","\u002Freference","10.reference",[297,301,305,309,313,317,321,325],{"title":298,"path":299,"stem":300},"FAQ","\u002Freference\u002Ffaq","10.reference\u002F01.faq",{"title":302,"path":303,"stem":304},"Tips and Tricks","\u002Freference\u002Ftips-and-tricks","10.reference\u002F02.tips-and-tricks",{"title":306,"path":307,"stem":308},"Errors and Warnings","\u002Freference\u002Ferrors-and-warnings","10.reference\u002F03.errors-and-warnings",{"title":310,"path":311,"stem":312},"Lengths","\u002Freference\u002Flengths","10.reference\u002F04.lengths",{"title":314,"path":315,"stem":316},"Counters","\u002Freference\u002Fcounters","10.reference\u002F05.counters",{"title":318,"path":319,"stem":320},"Boxes","\u002Freference\u002Fboxes","10.reference\u002F06.boxes",{"title":322,"path":323,"stem":324},"Rules and Struts","\u002Freference\u002Frules-and-struts","10.reference\u002F07.rules-and-struts",{"title":326,"path":327,"stem":328},"Command Glossary","\u002Freference\u002Fcommand-glossary","10.reference\u002F08.command-glossary",{"title":330,"icon":331,"path":332,"stem":333,"children":334,"page":30},"Appendices","i-lucide-bookmark","\u002Fappendices","11.appendices",[335,339,343,347],{"title":336,"path":337,"stem":338},"Package Reference","\u002Fappendices\u002Fpackage-reference","11.appendices\u002F01.package-reference",{"title":340,"path":341,"stem":342},"Sample LaTeX Documents","\u002Fappendices\u002Fsample-latex-documents","11.appendices\u002F02.sample-latex-documents",{"title":344,"path":345,"stem":346},"Links","\u002Fappendices\u002Flinks","11.appendices\u002F03.links",{"title":348,"path":349,"stem":350},"Authors","\u002Fappendices\u002Fauthors","11.appendices\u002F04.authors",{"id":352,"title":272,"body":353,"description":690,"extension":691,"links":692,"meta":693,"navigation":694,"path":273,"seo":695,"stem":274,"__hash__":696},"docs\u002F09.programming\u002F04.creating-package-documentation.md",{"type":354,"value":355,"toc":685},"minimark",[356,360,368,378,383,386,499,534,537,555,559,562,582,593,597,608,637,644,653,659,681],[357,358,359],"p",{},"Documentation is important for the end users to quickly know how to use your package. They are also helpful to other developers since they can make it easier to read your codes. Each programming language has its own ways to make documentation. For LaTeX, we generate pdf documentation from .dtx file.",[357,361,362,363,367],{},".dtx suffix is the acronym of ",[364,365,366],"em",{},"documentation TeX",". It has two kinds of functionality:",[369,370,371,375],"ul",{},[372,373,374],"li",{},"explain to users how to use commands in your package",[372,376,377],{},"format source codes for easier reading",[379,380,382],"h2",{"id":381},"basic-structure","Basic structure",[357,384,385],{},"Suppose you'd like to write a documentation for your newly created package called mypackage for example. The basic structure of .dtx file is like the following:",[387,388,393],"pre",{"className":389,"code":390,"language":391,"meta":392,"style":392},"language-latex shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","% \\iffalse meta-comment\n% Add copyright,author,version information\n% here for this documentation file\n% \\fi\n% \\iffalse\n%\u003C*driver>\n\\ProvidesFile{mypackage.dtx}[1.0 My package]\n\\documentclass{ltxdoc}\n\\begin{document}\n  \\DocInput{\\jobname.dtx}\n\\end{document}\n%\u003C\u002Fdriver>\n% \\fi\n% write normal LaTeX documentation content here\n% \\Finale\n%\n\\endinput\n","latex","",[394,395,396,404,410,416,422,428,434,440,446,452,458,464,470,475,481,487,493],"code",{"__ignoreMap":392},[397,398,401],"span",{"class":399,"line":400},"line",1,[397,402,403],{},"% \\iffalse meta-comment\n",[397,405,407],{"class":399,"line":406},2,[397,408,409],{},"% Add copyright,author,version information\n",[397,411,413],{"class":399,"line":412},3,[397,414,415],{},"% here for this documentation file\n",[397,417,419],{"class":399,"line":418},4,[397,420,421],{},"% \\fi\n",[397,423,425],{"class":399,"line":424},5,[397,426,427],{},"% \\iffalse\n",[397,429,431],{"class":399,"line":430},6,[397,432,433],{},"%\u003C*driver>\n",[397,435,437],{"class":399,"line":436},7,[397,438,439],{},"\\ProvidesFile{mypackage.dtx}[1.0 My package]\n",[397,441,443],{"class":399,"line":442},8,[397,444,445],{},"\\documentclass{ltxdoc}\n",[397,447,449],{"class":399,"line":448},9,[397,450,451],{},"\\begin{document}\n",[397,453,455],{"class":399,"line":454},10,[397,456,457],{},"  \\DocInput{\\jobname.dtx}\n",[397,459,461],{"class":399,"line":460},11,[397,462,463],{},"\\end{document}\n",[397,465,467],{"class":399,"line":466},12,[397,468,469],{},"%\u003C\u002Fdriver>\n",[397,471,473],{"class":399,"line":472},13,[397,474,421],{},[397,476,478],{"class":399,"line":477},14,[397,479,480],{},"% write normal LaTeX documentation content here\n",[397,482,484],{"class":399,"line":483},15,[397,485,486],{},"% \\Finale\n",[397,488,490],{"class":399,"line":489},16,[397,491,492],{},"%\n",[397,494,496],{"class":399,"line":495},17,[397,497,498],{},"\\endinput\n",[357,500,501,502,505,506,509,510,513,514,517,518,521,522,509,525,528,529,533],{},"When you run ",[394,503,504],{},"pdflatex mypackage.dtx",", you can generate mypackage.pdf, which is the manual. In this pdf file, all contents after the ",[394,507,508],{},"\\fi"," and ",[394,511,512],{},"\\endinput"," are stripped out of the comment and inserted between the document. Notice that the first time the LaTeX engine encounters ",[394,515,516],{},"\\DocInput",", it reads the same file again but strips all lines starting with %. As a result, it ignores the code block with ",[394,519,520],{},"\\iffalse ...\\fi",". It should also be noticed that the second pass of the same file also ignores the magic comments between ",[394,523,524],{},"%\u003Cdriver>",[394,526,527],{},"%\u003C*driver>",". The indicator ",[530,531,532],"strong",{},"driver"," manifests that the inner contents are a kind of wrapper to produce the final manual and you can replace them with other word as you like.",[357,535,536],{},"There are some macros which need some further explanations:",[369,538,539,549,552],{},[372,540,541,544,545,548],{},[394,542,543],{},"\\ProvidesFile{\u003Cname>}[\u003Cversion>]"," works similar to ",[394,546,547],{},"\\ProvidesPackage{\u003Cname>}[\u003Cversion>]",", it writes contents within the square brackets to the log file.",[372,550,551],{},"meta-comment is used to provide information of the .dtx file itself. As you can not use normal TeX comments, because they will be stripped.",[372,553,554],{},"ltxdoc is like other document class and provides some easy-to-use commands to write package documentation, which is illustrated below.",[379,556,558],{"id":557},"new-macro-description","New Macro Description",[357,560,561],{},"To describe macros defined in your package, you can use",[387,563,565],{"className":389,"code":564,"language":391,"meta":392,"style":392},"% \\begin{macro}{\\mymacro}\n% mymacro definition goes here\n% \\end{macro}\n",[394,566,567,572,577],{"__ignoreMap":392},[397,568,569],{"class":399,"line":400},[397,570,571],{},"% \\begin{macro}{\\mymacro}\n",[397,573,574],{"class":399,"line":406},[397,575,576],{},"% mymacro definition goes here\n",[397,578,579],{"class":399,"line":412},[397,580,581],{},"% \\end{macro}\n",[357,583,584,585,588,589,592],{},"The environment macro accepts a mandatory argument, which is the name of the macro and printed on the left margin. You can also use ",[394,586,587],{},"\\DescribeMacro{mymacro}"," and put the extra explanations on the normal text. For new environment description, you can use ",[394,590,591],{},"\\DescribeEnv{mynewenv}",". Their difference lies in the index entry type, which will be illustrated below.",[379,594,596],{"id":595},"index-entries-and-changes","Index Entries and Changes",[357,598,599,600,603,604,607],{},"Add ",[394,601,602],{},"\\EnableCrossrefs"," to the preamble of the package documentation file (without comment at line beginning). Add ",[394,605,606],{},"\\PrintIndex"," to the point where you'd like the index to appear. And all the macros you described will be printed at the end of the document. For the general introduction of making indices, see Compiling indices. Usually, the following building is enough:",[387,609,613],{"className":610,"code":611,"language":612,"meta":392,"style":392},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","makeindex -s gind.ist -o mypackage.ind mypackage.idx\n","bash",[394,614,615],{"__ignoreMap":392},[397,616,617,621,625,628,631,634],{"class":399,"line":400},[397,618,620],{"class":619},"sBMFI","makeindex",[397,622,624],{"class":623},"sfazB"," -s",[397,626,627],{"class":623}," gind.ist",[397,629,630],{"class":623}," -o",[397,632,633],{"class":623}," mypackage.ind",[397,635,636],{"class":623}," mypackage.idx\n",[357,638,639,640,643],{},"ltxdoc also provides the functionality to record package changes. To enable this feature, add ",[394,641,642],{},"\\RecordChanges"," to the preamble and use",[387,645,647],{"className":389,"code":646,"language":391,"meta":392,"style":392},"\\changes{v1.0}{2017\u002F01\u002F01}{create my package.}\n",[394,648,649],{"__ignoreMap":392},[397,650,651],{"class":399,"line":400},[397,652,646],{},[357,654,599,655,658],{},[394,656,657],{},"\\PrintChanges"," to the point where you'd like the index to appear. Changes are recorded with glossary support, invoke makeindex from command line:",[387,660,662],{"className":610,"code":661,"language":612,"meta":392,"style":392},"makeindex -s gglo.ist -o mypackage.gls mypackage.glo\n",[394,663,664],{"__ignoreMap":392},[397,665,666,668,670,673,675,678],{"class":399,"line":400},[397,667,620],{"class":619},[397,669,624],{"class":623},[397,671,672],{"class":623}," gglo.ist",[397,674,630],{"class":623},[397,676,677],{"class":623}," mypackage.gls",[397,679,680],{"class":623}," mypackage.glo\n",[682,683,684],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}",{"title":392,"searchDepth":406,"depth":406,"links":686},[687,688,689],{"id":381,"depth":406,"text":382},{"id":557,"depth":406,"text":558},{"id":595,"depth":406,"text":596},"Learn how to create documentation for LaTeX packages using .dtx files.","md",null,{},true,{"title":272,"description":690},"B0xDdNWhhzlH1kIWfLGsRdoQWLZ3F9hZ0L1im_9vds4",[698,700],{"title":268,"path":269,"stem":270,"description":699,"children":-1},"Learn how to create your own LaTeX packages and classes to organize commands and environments.",{"title":276,"path":277,"stem":278,"description":701,"children":-1},"Learn how to create custom LaTeX themes to change the visual appearance of your documents.",1785155513490]