4 ms·
> With "sideloading" of HTML there is no way in general to make sure that the contents of LaTeX (and PDF) on one side and HTML on the other side is the same. I
by dataflow 3y ago
> With "sideloading" of HTML there is no way in general to make sure that the contents of LaTeX (and PDF) on one side and HTML on the other side is the same.
Is it not possible to write LaTeX code that produces different contents in HTML vs. PDF?
- kennethologist 3y agoStraight from ChatGPT: Yes, it is indeed possible to write LaTeX code that produces different contents when compiled to HTML versus PDF. This is typically done by using conditional commands within the LaTeX document that check for the output format being used. These conditional commands can then include or exclude specific content based on whether the document is being compiled to HTML or PDF. In LaTeX, the ifpdf package is commonly used to check if the output is being compiled to a PDF. For generating HTML from LaTeX, tools like TeX4ht or LaTeX2HTML are used, and they often define their own specific commands or provide a way to detect the output format. ----- It gives simple code that uses: The \ifpdf ... \else ... \fi command checks if the document is being compiled to PDF. If it is, the content between \ifpdf and \else is included. If not (which would be the case for HTML), the content between \else and \fi is included. The content outside the \ifpdf ... \fi conditional will appear in both the PDF and HTML versions.
- IlliOnato 3y agoWell, perhaps by exploiting bugs/shortcomings in PDF and HTML converters. Not by design. However, bugs get fixed, and since the PDF and HTML are generated dynamically, any such hack would be extremely fragile. And while "single source of truth" can help to prevent such malicious discrepancy, it's unlikely that people would try to hack the system this way: what for? Far more likely scenario is unintentional discrepancy, and single source of truth definitely helps to prevent that!