Tag Info

Hot answers tagged

43

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 ...


16

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} }


16

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 ...


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 ...


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 ...


11

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 ...


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{...} ...


10

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 ...


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: ...


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

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

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


9

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]{!--}{--}, ...


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

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. ...


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 ...


7

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

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> ...


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.


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 ...


6

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}]{</}{>}, ...


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

\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} % ...


5

I would like to suggest the use of LibreOffice together with Writer2LaTeX. The converter works extraordinary well, produces nicely structured LaTeX files, handles properly mathematical formulae, images, headers, footers, special symbols and so on. And LibreOffice has a good (although not perfect) compatibility with Microsoft Word .doc files. Better download ...


5

TeXnicCenter allows for the creation of "user text modules" that are initiated via a shortcut. To insert your own module, follow Insert>Own Text Modules>Manage Text Modules. Now you can enter a new one called (say) Separator: Once you've established the correct "before cursor" and "after cursor" combination, it is accessible via the menu selection: Or ...


5

I think the reason why there are not publicly available DITA to PDF conversion via LaTeX is that no one has needed to make one. Technically it should be equally easy as generating XSL FO and processing that. For example DocBook seems to have conversion to LaTeX.


5

One of solution is this. first define your listingstyle like this before \begin{document} If your main Language is persian then: \documentclass[11pt]{book} \usepackage{listings} \usepackage{xepersian} \lstdefinestyle{MyXML}{ language=XML, escapeinside={\%*}{*)}, morekeywords={encoding, ...



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