Announcement

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

  • --markstat-- Troubleshooting

    I am trying to run the "simpleScript.stmd" example from the markstat documentation page and I am getting the following error:
    Code:
    Package hyperref Warning: Option `bookmarks' has already been used,
    (hyperref)                setting the option has no effect on input line 44.
    
    (./simpleScript.aux) (/usr/share/texmf/tex/latex/lm/t1lmr.fd)
    (/usr/share/texmf/tex/latex/microtype/mt-cmr.cfg)
    (/usr/share/texmf/tex/context/base/supp-pdf.tex
    [Loading MPS to PDF converter (version 2006.09.02).]
    ) (/usr/share/texmf/tex/latex/graphics/color.sty
    (/usr/share/texmf/tex/latex/config/color.cfg))
    (/usr/share/texmf/tex/latex/hyperref/nameref.sty
    (/usr/share/texmf/tex/latex/oberdiek/refcount.sty)) (./simpleScript.out)
    (./simpleScript.out) (/usr/share/texmf/tex/latex/lm/t1lmtt.fd)
    Runaway argument?
    width=\maxwidth ][width=0.75\linewidth ]{auto.pdf} \caption {Fuel Eff\ETC.
    ! Paragraph ended before \Gin@iii was complete.
    <to be read again>
                       \par
    l.85
         
    ? X
    No pages of output.
    Transcript written on simpleScript.log.
    I have successfully installed pdflatex, pandoc and whereis and finished the necessary configurations of whereis (as well as downloading the stata.sty file ono my working directory) as per instructions in the "Getting Started" page: http://data.princeton.edu/stata/markdown/gettingStarted
    As an aside, the error log seems to be referring to this snippet of the tex file, but I haven't been able to spot any syntax problems with how this tex code has been written.

    Code:
    \begin{figure}[htbp]
    \centering
    \includegraphics[width=0.75\linewidth]{auto.pdf}
    \caption{Fuel Efficiency}
    \end{figure}
    Any ideas as to what I am missing?

  • #2
    Have you looked earlier in the document? What does the header look like? It might be useful to copy/paste more of the LaTeX document here since it could be a problem that starts much earlier in the document and only becomes an issue when it gets to the point of attempting to insert the graphic.

    Comment


    • #3
      Hi,
      Good point, here is the full tex file generated by markstat after using a combination of the simple example and the "estimation tables" example:

      Code:
      \documentclass[]{article}
      \usepackage{stata}
      \usepackage[T1]{fontenc}
      \usepackage{lmodern}
      \usepackage{amssymb,amsmath}
      \usepackage{ifxetex}
      \usepackage{fixltx2e} % provides \textsubscript
      % use microtype if available
      \IfFileExists{microtype.sty}{\usepackage{microtype}}{}
      \ifnum 0\ifxetex 1\fi=0 % if pdftex
        \usepackage[utf8]{inputenc}
      \else % if xelatex
        \usepackage{fontspec}
        \ifxetex
          \usepackage{xltxtra,xunicode}
        \fi
        \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
        \newcommand{\euro}{€}
      \fi
      \usepackage{graphicx}
      % We will generate all images so they have a width \maxwidth. This means
      % that they will get their normal width if they fit onto the page, but
      % are scaled down if they would overflow the margins.
      \makeatletter
      \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
      \else\Gin@nat@width\fi}
      \makeatother
      \let\Oldincludegraphics\includegraphics
      \renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}
      \ifxetex
        \usepackage[setpagesize=false, % page size defined by xetex
                    unicode=false, % unicode breaks when used with xetex
                    xetex]{hyperref}
      \else
        \usepackage[unicode=true]{hyperref}
      \fi
      \hypersetup{breaklinks=true,
                  bookmarks=true,
                  pdfauthor={},
                  pdftitle={},
                  colorlinks=true,
                  urlcolor=blue,
                  linkcolor=magenta,
                  pdfborder={0 0 0}}
      \setlength{\parindent}{0pt}
      \setlength{\parskip}{6pt plus 2pt minus 1pt}
      \setlength{\emergencystretch}{3em}  % prevent overfull lines
      \setcounter{secnumdepth}{0}
      
      \author{}
      \date{}
      
      \begin{document}
      
      Let us read the fuel efficiency data that is shipped with Stata
      
      \begin{stlog}
      . sysuse auto, clear
      (1978 Automobile Data)
      \end{stlog}
      
      To study how fuel efficiency depends on weight it is useful to transform
      the dependent variable from ``miles per gallon'' to ``gallons per 100
      miles''
      
      \begin{stlog}
      . gen gphm = 100/mpg
      \end{stlog}
      
      We then obtain a more linear relationship
      
      \begin{stlog}
      . twoway scatter gphm weight || lfit gphm weight ///
      >     , ytitle(Gallons per Mile) legend(off)
      {\smallskip}
      . graph export auto.pdf, replace
      (file auto.pdf written in PDF format)
      \end{stlog}
      
      \begin{figure}[htbp]
      \centering
      \includegraphics[width=0.75\linewidth]{auto.pdf}
      \caption{Fuel Efficiency}
      \end{figure}
      
      That's all for now!
      
      \subsubsection{A Table of Estimates}
      
      The table below shows estimated differences in fuel efficiency between
      foreign and domestic cars with and without adjustment for weight, using
      gallons per 100 miles as the outcome.
      
      \begin{stlog}
      
      {\smallskip}
      
      {\smallskip}
      
      {\smallskip}
      
      {\smallskip}
      
      {\smallskip}
      
      {\smallskip}
      
      {\smallskip}
      \HLI{44}
                            (1)             (2)   
                           gphm            gphm   
      \HLI{44}
      foreign            -1.005**         0.622**
                        (-3.29)          (3.11)   
      {\smallskip}
      weight                            0.00163***
                                        (13.74)   
      {\smallskip}
      _cons               5.318***      -0.0735   
                        (31.92)         (-0.18)   
      \HLI{44}
      N                      74              74   
      \HLI{44}
      t statistics in parentheses
      * p<0.05, ** p<0.01, *** p<0.001
      \end{stlog}
      
      We see that on average foreign cars are more economical, but if we
      adjust for weight they are less fuel efficient, using 0.6 gallons
      \emph{more} instead of one gallon \emph{less} per 100 miles.
      
      \end{document}

      Comment


      • #4
        I could reproduce the problem using the LaTeX code in #1. However, when I produced the LaTeX myself from the code on the website instead I got the error message that the file "auto.png" was not found. The graph export file should be auto.png, not auto.pdf. I found a workaround "solution" by adding the file auto.png in the directory before running the markstat command:

        Code:
        markstat using simpleScript, strict pdf bib keep
        Last edited by Anders Alexandersson; 20 Aug 2018, 14:45. Reason: Made the wording more clear.

        Comment


        • #5
          Hi Anders,
          Thanks for the follow up! I am bit confused by the diagnosis -- shouldn't markstat be generating the png (or any other image file) within your working directory before creating the tex and compiling the tex file into pdf? By the way, I am running this on a UNIX terminal so I can't export to .png but I am getting the same error exporting to .eps.

          Here is my .stmd file
          Code:
          Let us read the fuel efficiency data that is shipped with Stata
          ```{s}
              sysuse auto, clear
          ```
          To study how fuel efficiency depends on weight it is useful to
          transform the dependent variable from "miles per gallon" to
          "gallons per 100 miles"
          ```{s}
              gen gphm = 100/mpg
          ```
          We then obtain a more linear relationship
          ```{s}
              twoway scatter gphm weight || lfit gphm weight ///
                  , ytitle(Gallons per Mile) legend(off)
              graph export auto.eps, replace
          ```
          ![Fuel Efficiency](auto.eps)
          
          That's all for now!
          
          ### A Table of Estimates
          
          The table below shows estimated differences in fuel efficiency between
          foreign and domestic cars with and without adjustment for weight, using
          gallons per 100 miles as the outcome.
          
          ```s/
              clear all
              quietly sysuse auto, clear
              quietly gen gphm = 100/mpg
              eststo clear
              quietly eststo: regress gphm foreign
              quietly eststo: regress gphm foreign weight
              esttab
          ```
          
          We see that on average foreign cars are more economical, but
          if we adjust for weight they are less fuel efficient, using
          `s %3.1f _b[foreign]` gallons *more* instead of one gallon
          *less* per 100 miles.

          Comment


          • #6
            shouldn't markstat be generating the png (or any other image file) within your working directory before creating the tex and compiling the tex file into pdf?
            I think that is a question for the author: German Rodriguez . In the markstat paper, the PDF troubleshooting advice is to run pdflatex directly on a console to see what went wrong. The simplest PDF solution that I am aware of for this case is to run the markstat command twice, like this:

            Code:
            markstat using simpleScript
            markstat using simpleScript, strict bib pdf keep

            Comment


            • #7
              I think it is possible that Hong-Yi Tu Ye is running an old version of Pandoc, perhaps one that was already installed in his system. The -markstat- command requires 2.0.5 or higher, the current version is 2.2.3.2. Troubleshooting details follow.

              First let me address the question in #5, referred to me by Anders Alexandersson in #6:

              shouldn't markstat be generating the png (or any other image file) within your working directory before creating the tex and compiling the tex file into pdf?
              The answer is yes, -markstat- generates and runs a do file that includes the -graph export- command. You just have to be careful to use the same filename and extension in the Markdown syntax to include the file, as Anders noted in #4.

              I copied and pasted Hong-Yi Tu Ye 's stmd script from #5, except that I changed eps to pdf, and it ran fine on my system. No surprises there.

              Hong-Yi Tu Ye was kind enough to provide the generated LaTeX code in #3. Running this directly through pdflatex I was able to reproduce the error, just like Anders did. I run CSdiff to compare that with the LaTeX generated in my system and the preamble is quite different, which led me to think that we are using different versions of Pandoc. In particular, the script in #3 redefines the \includegraphics command.

              Now Pandoc by default sizes graphs in LaTeX documents to the full page width. In contrast, -markstat- sets the size to 75% of the width, unless the user has specified otherwise. This is done by patching the generated \includegraphics command. Unfortunately, the patch doesn't work with the redefined command in #3. This is the source of the error. It also suggests a possible workaround: just specify the width, using the syntax
              Code:
              ![Fuel Efficiency](auto.eps){width=80%}
              I think this is likely to work, but a much better solution is to upgrade Pandoc.

              Comment


              • #8
                German Rodriguez Ah that makes sense! Indeed, the pandoc install on the server I'm working on is 1.9.4.1. Thanks for resolving this mystery!

                Comment


                • #9
                  German Rodriguez
                  Thank you, unfortunately the fix in #7 did not help my problem in #4 (which uses png rather than eps for the graph). I use Windows 7 (x64).

                  That is, I upgraded pandoc from version 2.1.3 (the webpage http://data.princeton.edu/stata/markdown/gettingStarted refers to 2.0.5) to version 2.2.3.2 and I changed the simpleScript.stmd line to
                  Code:
                   
                   ![Fuel Efficiency](auto.png){width=80%}

                  The error is the same that the file "auto.png" was not found. This is the actual error message in the LaTeX console:


                  Code:
                  LaTeX Warning: File `auto.png' not found on input line 93.
                  
                  ! Package pdftex.def Error: File `auto.png'  not found.
                  My two-line fix in #6 still works (and the actual width of "auto.png" changes to 80% as expected).




                  Comment


                  • #10
                    Anders Alexandersson I am afraid I can't reproduce your error. I copied the script at #5 to a clean working directory, changed.eps to .png, and it ran fine. Your fix in #6 works, but I believe it is running the do file and generating the auto.png file twice.

                    It is possible to verify this. When you run -markstat- the Stata results window will echo the graph export command, with confirmation that auto.png was generated. (Or specify keep and then look at the smcl file.) On my run it says (file auto.png written in PNG format).

                    Regarding Pandoc versions, all you need is 2.0.5 as the web page says. Version 2.1.3 should be fine, as is the current version 2.2.3.2.

                    Comment


                    • #11
                      German Rodriguez



                      This is simpleScript.tex that generates the error:

                      Code:
                      \PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
                      \PassOptionsToPackage{hyphens}{url}
                      %
                      \documentclass[]{article}
                      \usepackage{stata}
                      \usepackage{lmodern}
                      \usepackage{amssymb,amsmath}
                      \usepackage{ifxetex,ifluatex}
                      \usepackage{fixltx2e} % provides \textsubscript
                      \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}
                        \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
                      \fi
                      % use upquote if available, for straight quotes in verbatim environments
                      \IfFileExists{upquote.sty}{\usepackage{upquote}}{}
                      % use microtype if available
                      \IfFileExists{microtype.sty}{%
                      \usepackage[]{microtype}
                      \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
                      }{}
                      \IfFileExists{parskip.sty}{%
                      \usepackage{parskip}
                      }{% else
                      \setlength{\parindent}{0pt}
                      \setlength{\parskip}{6pt plus 2pt minus 1pt}
                      }
                      \usepackage{hyperref}
                      \hypersetup{
                                  pdfborder={0 0 0},
                                  breaklinks=true}
                      \urlstyle{same}  % don't use monospace font for urls
                      \usepackage{graphicx,grffile}
                      \makeatletter
                      \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
                      \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
                      \makeatother
                      % Scale images if necessary, so that they will not overflow the page
                      % margins by default, and it is still possible to overwrite the defaults
                      % using explicit options in \includegraphics[width, height, ...]{}
                      \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
                      \setlength{\emergencystretch}{3em}  % prevent overfull lines
                      \providecommand{\tightlist}{%
                        \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
                      \setcounter{secnumdepth}{0}
                      % Redefines (sub)paragraphs to behave more like sections
                      \ifx\paragraph\undefined\else
                      \let\oldparagraph\paragraph
                      \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
                      \fi
                      \ifx\subparagraph\undefined\else
                      \let\oldsubparagraph\subparagraph
                      \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
                      \fi
                      
                      % set default figure placement to htbp
                      \makeatletter
                      \def\fps@figure{htbp}
                      \makeatother
                      
                      
                      \date{}
                      
                      \begin{document}
                      
                      Let us read the fuel efficiency data that is shipped with Stata
                      
                      \begin{verbatim}
                      sysuse auto, clear
                      \end{verbatim}
                      
                      To study how fuel efficiency depends on weight it is useful to transform
                      the dependent variable from ``miles per gallon'' to ``gallons per 100
                      miles''
                      
                      \begin{verbatim}
                      gen gphm = 100/mpg
                      \end{verbatim}
                      
                      We then obtain a more linear relationship
                      
                      \begin{verbatim}
                      twoway scatter gphm weight || lfit gphm weight ///
                          , ytitle(Gallons per Mile) legend(off)
                      graph export auto.png, width(500) replace
                      \end{verbatim}
                      
                      \begin{figure}
                      \centering
                      \includegraphics[width=0.8\textwidth,height=\textheight]{auto.png}
                      \caption{Fuel Efficiency}
                      \end{figure}
                      
                      That's all for now!
                      
                      \end{document}
                      If I press "Enter", then the PDF is generated but the "graph" is just a big empty box with the text auto.png left-centered. I can also reproduce the result by running the tex file using TexWorks.

                      The Stata do file has little content:

                      Code:
                      capture log close
                      log using "simpleScript", smcl replace
                      //_^
                      log close
                      The SMCL file therefore has correspondingly little content:

                      Code:
                      {smcl}
                      {txt}{sf}{ul off}{.-}
                            name:  {res}<unnamed>
                             {txt}log:  {res}C:\Data\simpleScript.smcl
                        {txt}log type:  {res}smcl
                       {txt}opened on:  {res} 4 Sep 2018, 14:16:27
                      {txt}
                      {com}. //_^
                      . log close
                            {txt}name:  {res}<unnamed>
                             {txt}log:  {res}C:\Data\simpleScript.smcl
                        {txt}log type:  {res}smcl
                       {txt}closed on:  {res} 4 Sep 2018, 14:16:27
                      {txt}{.-}
                      {smcl}
                      {txt}{sf}{ul off}
                      For completeness, this is the stmd file:

                      Code:
                      Let us read the fuel efficiency data that is shipped with Stata
                      
                          sysuse auto, clear
                      
                      To study how fuel efficiency depends on weight it is useful to
                      transform the dependent variable from "miles per gallon" to
                      "gallons per 100 miles"
                      
                          gen gphm = 100/mpg
                      
                      We then obtain a more linear relationship
                      
                          twoway scatter gphm weight || lfit gphm weight ///
                              , ytitle(Gallons per Mile) legend(off)
                          graph export auto.png, width(500) replace
                      
                      ![Fuel Efficiency](auto.png){width=80%} 
                      
                      That's all for now!
                      Finally, this is the Stata command I run to reproduce the error in Stata (it does not produce auto.png). I don't use a bibliography here but bib is included for completeness:

                      Code:
                      markstat using simpleScript, strict bib pdf keep







                      Comment


                      • #12
                        Anders Alexandersson thanks for providing all this detail, I can see the problem now. The stmd script you provide in #11 uses the simple syntax, with Stata code indented one tab or four spaces. But the command you show immediately below that has the strict option, which tells markstat that Stata commands are enclosed in code fences. Because there are no code fences in your script, markstat sees no Stata code, which is why the do and smcl files have little content, and the auto.png file is not generated. I think if you leave out the strict option the script will run fine.

                        Comment


                        • #13
                          German Rodriguez Yes, my bad. Thank you.

                          Comment

                          Working...
                          X