Tag Info

Hot answers tagged

40

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

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


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

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

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

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


7

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 be TeX, ...


7

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


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


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

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

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


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

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


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

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

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


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

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

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

You might consider pandoc. Pandoc uses "templates" to convert an input format into pandoc's markdown format, which can then be converted into any other format with a supported template. The official templates repository lists both texinfo and latex templates, so that's where I'd start.


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


4

With listings you can do the following: \lstMakeShortInline{|} And then use it thus: |<tag1>| and it will be printed using the listings style, and syntax highlighting and so on. You could use a symbol other than | if you so wished.


4

I'm a university lecturer -- now also programme director -- in engineering. For me TeX/LaTeX is still unbeatable for writing research papers etc., but DITA is the perfect medium for teaching materials in STEM subjects: it imposes a highly structured style which students need, and the range of online and print output media now available is amazing. DITA's ...



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