Tag Info

Hot answers tagged

49

You can define your own language. The best I could get so far: \usepackage{listings} \usepackage{color} \definecolor{gray}{rgb}{0.4,0.4,0.4} \definecolor{darkblue}{rgb}{0.0,0.0,0.6} \definecolor{cyan}{rgb}{0.0,0.6,0.6} \lstset{ basicstyle=\ttfamily, columns=fullflexible, showstringspaces=false, commentstyle=\color{gray}\upshape } ...


19

DocBook is certainly the standard for XML documentation writing. I've heard of DITA, but couldn't tell you much about it. You can use ConTeXt to process XML. It works by defining a mapping between the XML tags and TeX markup instructions. This should give you the benefits of DocBook (universal, XML-based) and many of the benefits of ConTeXt in the document ...


18

I would consider (La)TeX to be ideally suited for exactly the purpose you mention. It is definitely flexible in the sense that you can follow a very basic approach of typesetting simple elements (you mention paragraphs and figures), and tweaking the layout at a later stage (table of contents, margins, stock-size). The latter is typically obtained via the ...


17

XML language is very limited supported. You can define more keywords yourself: \lstset{ language=XML, morekeywords={encoding, xs:schema,xs:element,xs:complexType,xs:sequence,xs:attribute} }


13

The problem is that the following two lines in your \lstdefinelanguage{XML} are in conflict: morestring=[s]{>}{<}, morecomment=[s][\color{orange}]{<!--}{-->}, In addition, doesn't \lstdefinelanguage{XML} redefine the XML language settings, thereby losing a lot of configs? One of the most noticeable drawbacks is that you can no longer access ...


13

XML is a file format not a language of any sort so asking for a general XML to latex is like asking for ASCII to latex. In general it depends what is in the XML file, one would not expect the same latex formatting for an XSLT program as a XHTML document, just because they both happened to use an XML syntax. In general you need to specify the styling you ...


12

There's every reason to expect that you'll succeed brilliantly with LaTeX in your endeavor to get your planned book published. Focusing on the content is certainly always an excellent strategy. As you write various chapters, try to separate decisions over content from decisions about how the content may/should be formatted. That said, I wonder if you ...


12

Here's another style which is rather hacky and stingy about additional whitespace because of the attribute delimiter that starts with a space: \definecolor{maroon}{rgb}{0.5,0,0} \definecolor{darkgreen}{rgb}{0,0.5,0} \lstdefinelanguage{XML} { basicstyle=\ttfamily, morestring=[s]{"}{"}, morecomment=[s]{?}{?}, morecomment=[s]{!--}{--}, ...


11

How does this XML system integrate with the rest of ConTeXt? It integrates extremely well through special xmlsetups. These setups let you define the behaviour for every element of the input tree. For more info consult the Context XML documentation or ask on the list. Why would anyone use such a system? Because you can rarely demand that the input ...


10

LaTeX already separates content from formatting. E.g. the look of \section{ABC} can be different depending on packages and classes. It is also easy to translate your XML-example in something more LaTeX-like e.g. \begin{timeline}{title=Australian History} \timepoint{year=60000BC,event=Aboriginal Migration,text=Aboriginal ...} \timepoint{...} ...


9

minted can’t do that and since I have no idea how this line-breaking feature is implemented in listings there are no plans a the moment to add the feature. Sorry. :-( My advice: for your situation, switch to listings (or break the lines manually).


9

The definition of a new command would be the easiest way to go. \newcommand*{\xml}[1]{\texttt{<#1>}} Use it in your document as \xml{tag}.


9

I don't know about the possible solutions with LaTeX and pdftex engine, but ConTeXt MkIV (which uses LuaTeX engine) supports an XML backend that is used to generate EPUB and tagged PDF. To get the XML output from a file, you need to add \setupbackend[export=yes] As an example, consider a simple file with some figures, math, and lists. ...


9

ConTeXt can directly process XML. See Thomas's MyWay and the official documentation


9

As described in your question the package listings can automatically break long lines. The is limited. The package breaks only on characters which are defined as others. To allow the break at every point you must say listings that a letter isn't a letter. This can be done be redefining the following definition: Original: ...


8

A synthesis of the previous answers that works best for me, especially w.r.t. highlighting the angle brackets. Using SVG Color names (svgnames): \lstdefinelanguage{XML} { basicstyle=\ttfamily\footnotesize, morestring=[b]", moredelim=[s][\bfseries\color{Maroon}]{<}{\ }, moredelim=[s][\bfseries\color{Maroon}]{</}{>}, ...


8

When you add the color package and change morestring=[b]", into morestring=[b][\color{red}]", the attributes will color red. This will color the attributes red in your xml listings. \begin{lstlisting}[language=xml, frame=single] <xml> <person age="22" sex="female">Ann</person> </xml> \end{lstlisting} ...


8

Explanation: I am using twocolumns so you can see how the lines will break with each option (and how bad it can get). The first option (texttt) will produce the desired result since you have no characters to escape in the present case, but the line breaking will be messed up because TeX is not geared for this. The second option (\verb or verbatim ...


8

Try this code: \documentclass[12pt]{amsart} \usepackage{geometry} \usepackage{listings} \usepackage{color} \usepackage[usenames,dvipsnames,svgnames,table]{xcolor} \geometry{a4paper} \begin{document} This is a sample file: \lstset{ language=xml, tabsize=3, %frame=lines, caption=Test, label=code:sample, frame=shadowbox, ...


7

Do not put the XML path selector in the setup name: the \startxmlsetups ... \stopxmlsetups is just defining a command, not actually selecting items from the XML file. It is \xmlsetsetup that does the XML object selection. I am not a heavy user of ConTeXt's xml support myself, but I think you need something like this: ...


7

tex4ht can convert to XHTML and MathML. See my answer to this question.


7

Here is the general idea with the luaxml "package". \documentclass{article} \usepackage{luacode} \begin{luacode*} xml = require('luaxml-mod-xml') handler = require('luaxml-mod-handler') \end{luacode*} \begin{document} \begin{luacode*} sample = [[ <DATA> <NAME="name" /> <VERSION="1" /> <VARIABLES> <TEST> ...


6

\sbox0{\lstinputlisting{example.xml}} \lstinputlisting[firstline=4,lastline=\the\numexpr\value{lstnumber}-5\relax]{example.xml} This save your input file in a box to count its lines number (so the file is not typeset in the document). This number is saved in the lstnumber counter so you can then use it to set your last line when you really insert the code. ...


6

I think there is also another way: LaTeXML: A LaTeX to XML Converter. After having install it, one might proceed as follows. Consider the following MWE called test_xml.tex: \documentclass[a4paper,11pt]{article} \usepackage{graphicx} \begin{document} Here is some text that precedes the image. \begin{figure} \includegraphics[scale=0.5]{ctan_lion} % ...


6

There is the DocBook XML format which you can use for books or other form of documentation. There is for example Apache FOP which can compile it to PDF. The advantage is that it can be converted to other formats like HTML much more easily than LaTeX. I know it from the Subversion book which is written in DocBook XML because the publisher O'Reilly Media wants ...


6

You certainly can use XSLT to generate TeX from XML for typesetting. That is how the PDF version of the MathML spec is produced for example. however the details depend greatly on the XML vocabulary used for input (and of course on the typesetting requirements for output). If you don't want to literally use XML syntax in the input document, then many of the ...


5

The problem with this question is that you are essentially asking for an XSLT transformation straight to your desired layout. There cannot be a clean solution to that, as the 'your desired layout' part is specific to you. TEI only defines structure, not visual appearance, so the appearance part has to come from somewhere else. If you want to make full use ...


5

You could use DocBook, and convert to LaTeX with Pandoc. pandoc -f docbook -t latex yourfile.docbook DocBook is pretty well documented. As an alternative to a more structured format, Emacs org-mode can give you plenty of features in a text format, with many export options including LaTeX.


5

As per Mico's answer to using bold italic text inside listings, there is no boldfaced mono spaced font in the Computer Modern font family, so you need to use a font that has a bold mono spaced font. Borrowing from this earlier question on XML syntax highlighting, here is an example: Known Issues: I am not sure why the very first non-comment < was ...


5

The minted package produces code which has tag-names, attribute-names, attribute-values and tag-contents printed differently, so the following code would produce the output which follows it: \documentclass{minimal} \usepackage{minted} \begin{document} \begin{minted}{xml} <xml> <person age="22" sex="female">Ann</person> ...



Only top voted, non community-wiki answers of a minimum length are eligible