3

I want to include a didactic, compact view of a DTD (Document Type Declaration) in my texts.

DTDs are used to define the set of tags and attributes of a XML/SGML document -- some sort of a grammar of the document.

Verbatim DTD are too verbose and ugly.

Is there any \usepackage for:

  • DTD pretty-printing?
  • or for DTD diagrams?

I don't mind loosing/hiding some DTD details.

7

If it is Document type definitions that you want, Pygments has support for it and produces a very neat output imo.

For LaTeX documents you can harness it easily with the minted-package, e.g.:

\documentclass{article}

\usepackage{minted}
\usemintedstyle{autumn}

\begin{document} 

\begin{minted}{dtd}

<!-- TEI P4 DTD. Generated 2004-07-15T16:23:29-04:00 by odd2dtd.xsl -->

<!-- 17.1.2: Certainty and uncertainty-->
<!--
 ** Copyright 2004 TEI Consortium.
 ** See the main DTD fragment 'tei2.dtd' or the file 'COPYING' for the
 ** complete copyright notice.
-->
<!ENTITY % certainty 'INCLUDE' >
<![ %certainty; [

<!ELEMENT %n.certainty; %om.RO;  EMPTY> 
<!ATTLIST %n.certainty;
     %a.global;
     target IDREFS #REQUIRED
     locus CDATA #REQUIRED
     assertedValue CDATA #IMPLIED
     desc CDATA #IMPLIED
     given CDATA #IMPLIED
     degree CDATA #IMPLIED
     TEIform CDATA 'certainty'  >
]]>  
<!-- 17.2: Responsibility for markup-->
<!ENTITY % respons 'INCLUDE' >
<![ %respons; [

<!ELEMENT %n.respons; %om.RO; EMPTY> 
<!ATTLIST %n.respons;
     %a.global;
     target IDREFS #REQUIRED
     locus CDATA #REQUIRED
     resp CDATA #REQUIRED
     desc CDATA #IMPLIED
     TEIform CDATA 'respons'  >
]]>  
<!-- end of 17.2-->
<!-- end of 17.1.2-->

\end{minted}

\end{document}

Note that you have to have python and pygments installed on your system and call LaTeX with -shell-escape.

enter image description here

  • If you add an image of the output, the quality of your answer will be much improved. – Steven B. Segletes Nov 5 '15 at 11:37
  • @Florian, thank you. I will study minted -- it helped (+1) -- much better then verbatim. Although TEI is a too violent example, I need to work out some way of improving its readability. – JJoao Nov 5 '15 at 12:14
  • @StevenB.Segletes, here is the pdfoutput I obtained. – JJoao Nov 5 '15 at 12:17
  • If you are not aware, you can edit your answer and literally include it in the answer, either as an uploaded image (preferred for archival reasons) or as a web pointer (which is what I did with jjoao's pointer). – Steven B. Segletes Nov 5 '15 at 12:21
  • 1
    @Florian, don't forget that the file types that can be uploaded are stack-exchange wide, and pdf can't be displayed nicely inline. – Chris H Nov 9 '15 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.