Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Markstat to latex troubleshooting

    Hi all, I am using and enjoying a lot, the markstat command written by German Rodriguez. I have successfully installed pandoc, whereis and downloaded the stata.sty file. Everything works fine when I try to compile an HTML or DOCX file, the issue starts when I try to generate a PDF using MixTeX (2.9 updated) which is my LaTeX installation.

    When I run the "simpleScript.stmd" example from the markstat documentation page with the command:
    Code:
    markstat using simpleScript, pdf
    the pdf does not compile, but a Tex file is created. I show here the preamble of the TeX document
    Code:
    \PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
    
    \PassOptionsToPackage{hyphens}{url}
    
    %
    
    \documentclass[
    \usepackage{stata}
    ]{article}
    
    \usepackage{lmodern}
    
    \usepackage{amssymb,amsmath}
    
    \usepackage{ifxetex,ifluatex}
    
    \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
    
    \usepackage[T1]{fontenc}
    
    \usepackage[utf8]{inputenc}
    
    \usepackage{textcomp} % provides euro and other symbols
    
    \else % if luatex or xelatex
    
    \usepackage{unicode-math}
    
    ...
    You will notice that for some reason that I cannot understand
    Code:
    \usepackage{stata}
    is within the square brackets of the \documentclass. This is causing all the trouble. If I manually take it out of the brackets the PDF compiles just fine. So not a huge issue, but it is a bit annoying and in any case, I would like to understand what is causing the issue.

    Any idea?




  • #2
    Hi Jacopo Mazza. Thanks for reporting this issue. Turns out this is due to a change introduced in Pandoc 2.7, which modified the LaTeX template in a way that broke markstat. Currently the code goes through the first few lines of the generated LaTeX looking for a line starting with \documentclass and inserts \usepackage{stata} immediately after that. Unfortunately, in the new template \documentclass spans at least two lines, and that causes markstat to insert the Stata style in the wrong place!

    I am testing possible fixes that will work with Pandoc 2.7 as well as earlier versions, and will update the command in SSC as soon as possible. In the meantime, a quick fix is to have markstat look for {article} or {beamer} instead, changing the line that reads if(startsWith(line, "\documentclass")) { to if(ustrpos(line,"{article}") > 0 || ustrpos(line,"{beamer}") > 0) {, at least while I come up with something more robust.

    Comment

    Working...
    X