I'm trying to understand if LaTeX is a good choice for my use case(s). I don't know LaTeX and am having a hard time finding if these things are all possible, or maybe it is more a compiler question?

  • I'm trying to create a document for a software product that gets rebranded depending on the customer we sell it to.
  • Need a text based documentation so multiple developers can update it and it can get merged together without issue in version control.
  • The document needs to support themes - different colors and styles (look and feel)
  • The document needs to be able to use variables that can be replaced when converted. e.g. {customer name} -> compile to PDF -> Walmart
  • The document should support either conditionals, or someway to have a "customer style" that can be attached at compile time. Like: compile latex --customer:walmart.style
  • Needs to output PDF, optionally also output HTML.

In searching the internet, I keep coming back to LaTeX, but I'm having a hard time differentiating what is the documentation language providing vs the compiler.

So, can this be done with LaTeX? If so, do I need a particular compiler? If not, any suggestion on a product that might provide something like this?


Wow, this is a very active and helpful community, thanks for all the responses!

Here is an example today of what is used, but it is not meeting the needs:

  1. Developers/Humans write the document using markdown

    that help your institution function more effectively.
    ![](md_images/media/image2.png){ width=90% }
    # Hardware Requirements
    1.  Single Tier system (windows + CIE + SQL) - recommended for low-medium volume sites:
        **BASE**  (supports up to 4 Channels high volume):

    This is then run through pandoc with MiKTeX and a .css style to produce a .doc, HTML, and PDF. However, it can't handle variables or conditionals very well, and the look and feel needs to be done all in CSS which can add alot of overhead, especially trying to go across the output file types.

    This will produce an output like:

    enter image description here

  2. Would like to have some type of system that works similar to this (which does not work today, it's just photoshopped):

    # Hardware Requirements for {customer}

    would output something like:

    enter image description here


Trying to address the hold question:

  • Does LaTeX support branding? For example, look & feel, replaceable variables and conditional text.
  • Can LaTeX be outputted to PDF, HTML and .docx using a single base document + a branding style sheet?
  • 5
    1. yes, 2. yes, 3. yes, 4. gut feeling says "yes", 5. see 4., 6. yes. see tex.stackexchange.com/questions/39309/convert-latex-to-html – naphaneal Mar 19 '18 at 17:18
  • 2
    do you have an example of data and required output style? – michal.h21 Mar 19 '18 at 18:19
  • 1
    Have you seen Sphinx? – cmhughes Mar 19 '18 at 20:07
  • 1
    LaTeX is great for human-authored documents, e.g. it has code for implementing things that would be cumbersome for a human (automatic section numbering, sorted bibliography, easily updated references to other sections, consistent typesetting, …). But for things that aren't human-authored, I would recommend not using LaTeX directly, except for the typesetting (to get a PDF). Make your own system that collects the data and processes the conditionals etc., and have it populate either a HTML template (to generate the HTML file) or (La)TeX template (to generate the PDF file). – ShreevatsaR Mar 19 '18 at 21:24
  • @ShreevatsaR I assume the developers who need to be able to edit it are human beings, so I take it you're suggesting that the actual documentation part not be LaTeX either, though I'm not clear why as this seems just the kind of case where it is better for developers to write e.g. \section{This bit} rather than 5. This bit or whatever. But I fear I have misunderstood? – cfr Mar 19 '18 at 23:20

The question is a little nebulous and open ended but one approach that you could use would be to have separate "style" files for each customer and then have the main file dynamically load the appropriate style when you compile the document.

To be more explicit, suppose that your main document file was the somewhat artificial main.tex


\expandafter\usepackage\expandafter{\customer}% load customer data


  \item[Customer name] \customerName
  \item[Address] \address
  \ifPaying\item[Account] \accountNumber\fi


and that have two customer files customer1.sty


and customer2.sty


Then you can use the following trick to dynamically set the customer to customer1 when you compile the document:

pdflatex -jobname=main "\def\customer{customer1}\input{main}"

With the files above this will produce a PDF file main.pdf:

enter image description here

Similarly, the command

pdflatex -jobname=main "\def\customer{customer2}\input{main}"

will produce a variant of the "same" document for customer2:

enter image description here

By the way, you could also use something like

pdflatex -jobname=main-customer2 "\def\customer{customer2}\input{main}"

to produce the customised PDF file name of main-customer2.pdf, or anything you liked.

In the examples above I have used colour and the the conditional \ifPaying because these features were mentioned in the question but the example is a little contrived and I would probably not use code like this in practice (for example, instead of using \ifPaying I would probably use \iscsdef{accountNumber} from the etoolbox package). Please consider adding a minimal working example to your question to better illustrate what you really want.

Conversion to HTML is potentially problematic. If your documents are "not very complicated" this should be straightforward but complicated documents are always harder to convert. Either way, from LaTeX I recommend using tex4ht. This is highly configurable and can almost certainly do what you want but the flip-side of being highly configurable is that you need to learn how to configure it. Using something like sphinx, as suggested in the comments, or writing code to dynamically generate latex or html output might be a better approach. It's not possible to recommend any particular approach without more concrete details of what you need and what your customer data looks like and how it is stored and accessed.

  • Thank you this is an extremely helpful example to help me understand if/how to use LaTeX for these use cases! – John S. Mar 20 '18 at 18:03

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