Announcement

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

  • Accessing GhostScript in Stata on Mac OS X

    Hi,

    I have tried to access GhostScript via Stata on Mac OS X but it doesn't seem to work. The gs command works when invoked from the terminal.
    Code:
    . shell gs
    
    /bin/bash: gs: command not found
    Kind regards,
    Konrad
    Version: Stata/IC 13.1

  • #2
    Two options come to my mind.

    1) Find where ghostscript is installed on your machine, and specify the full path like in Windows.

    2) It appears that you might be able to edit your .bash profile to look in the right directory. For whatever reason, the formal terminal application is looking in a wider range of places for the installation, or uses a different shell with a different profile than what Stata accesses. Actually, I don't know how OS-X processes Stata shell commands (does it even read your .bash_profile profile?) so you might be stuck with idea 1.

    Ah. Try
    shell /usr/local/bin/gs
    Last edited by ben earnhart; 27 Nov 2014, 11:10.

    Comment


    • #3
      Ben,

      Thanks very much for your help, the full path worked like a charm:
      Code:
      . #delimit ;
      delimiter now ;
      . shell /usr/local/bin/gs
      >         -dSAFER -dBATCH -dNOPAUSE
      >         -r100 -g1100x800 -sDEVICE=png16m
      >         -dGraphicsAlphaBits=4 -dTextAlphaBits=4
      >         -sOutputFile="jsa.png" "jsa.ps";
      
      GPL Ghostscript 9.15 (2014-09-22)
      Copyright (C) 2014 Artifex Software, Inc.  All rights reserved.
      This software comes with NO WARRANTY: see the file PUBLIC for details.
      Loading NimbusSanL-Regu font from /usr/local/Cellar/ghostscript/9.15/share/ghostscript/Resource/
      > Font/NimbusSanL-Regu... 4166112 2610892 6209992 4912112 1 done.
      Kind regards,
      Konrad
      Version: Stata/IC 13.1

      Comment


      • #4
        This workaround doesn't work for binaries that call other binaries. For example:
        Code:
        . shell latexmk -pdf ~/path/to/folder/
        
        /bin/bash: latexmk: command not found
        Shoot, I have to specify the full path. Try again:
        Code:
        . shell /usr/texbin/latexmk -pdf ~/path/to/folder/
        
        Latexmk: This is Latexmk, John Collins, 1 January 2015, version: 4.41.
        Rule 'pdflatex': Rules & subrules not known to be previously run:
           pdflatex
        Rule 'pdflatex': The following rules & subrules became out-of-date:
              'pdflatex'
        ------------
        Run number 1 of rule 'pdflatex'
        ------------
        ------------
        Running 'pdflatex  -recorder  "/Users/nilswork/path/to/folder/"'
        ------------
        Latexmk: applying rule 'pdflatex'...
        sh: pdflatex: command not found
        Collected error summary (may duplicate other messages):
          pdflatex: (Pdf)LaTeX failed to generate the expected log file '.log'
        Latexmk: Did not finish processing file '/Users/nilswork/path/to/folder/':
           (Pdf)LaTeX failed to generate the expected log file '.log'
        Latexmk: Use the -f option to force complete processing,
         unless error was exceeding maximum runs of latex/pdflatex.
        Latexmk: Errors, so I did not complete making targets
        Of course, I can run pdflatex individually with shell /usr/texbin/pdflatex, but that doesn't help me run latexmk.

        Locations appended to $PATH in .bash_profile don't have any effect.

        I don't know if this is supposed to work, but for the record:
        Code:
        . shell echo $PATH
        
        
        
        .
        edit: I found a workaround for the workaround. Use the -pdflatex argument of latexmk to specify the full path of pdflatex. Thus:

        Code:
        shell /usr/texbin/latexmk -pdf -pdflatex="/usr/texbin/pdflatex --shell-escape %O %S" ~/path/to/folder/
        This only helps with latexmk specifically, due to the existence of the convenient -pdflatex argument.
        Last edited by Nils Enevoldsen; 07 Jan 2015, 18:06.

        Comment


        • #5
          Replying to myself with a cleaner and more general solution.

          Incorrect syntax:
          Code:
          shell echo $PATH
          Corrected syntax:
          Code:
          shell echo \$PATH
          /usr/bin:/bin:/usr/sbin:/sbin
          Hence:
          Code:
          shell PATH=\$PATH:/usr/local/bin:/usr/texbin && latexmk etc…
          This is more robust than specifying the full path to each command, as latexmk illustrates.

          Thanks to Phil Clayton for the proper syntax.
          Last edited by Nils Enevoldsen; 21 Jan 2015, 15:47. Reason: Removed unneeded escape

          Comment


          • #6
            I came back to this discussion, as I'm trying to generate a set of PDF tables via tabout (SSC). I've created bot/top files and I'm trying to run the code below. The tabout syntax seems to be fine as I can generate tables in CSV or HTM with no problems. but when trying to run the conversion I keep on getting the error below.

            Code:
            // Commence the loop to generate a crosss tabulation on a LA level
            foreach cvar of varlist `crossvars' {
                *Generate the table using tabout
                tabout duma5 `cvar' using `cvar'_la_tab.tex, replace cells(row) format(2) ///
                    style(tex) svy percent body  noborder show(all) npos(both) ///
                    clab(_) stats(chi2) topf(top.tex) botf(bot.tex)
                * Compile the file in shell
                shell /usr/texbin/latexmk -pdf -pv `cvar'_la_tab.tex
            }
            // Restore
            restore
            Error
            Code:
            Latexmk: This is Latexmk, John Collins, 10 Nov 2013, version: 4.39.
            **** Report bugs etc to John Collins <collins at phys.psu.edu>. ****
            Rule 'pdflatex': Rules & subrules not known to be previously run:
               pdflatex
            Rule 'pdflatex': The following rules & subrules became out-of-date:
                  'pdflatex'
            ------------
            Run number 1 of rule 'pdflatex'
            ------------
            ------------
            Running 'pdflatex  -recorder  "wi1_la_tab.tex"'
            ------------
            Latexmk: applying rule 'pdflatex'...
            This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex)
             restricted \write18 enabled.
            entering extended mode
            (./wi1_la_tab.tex
            LaTeX2e <2014/05/01>
            Babel <3.9k> and hyphenation patterns for 78 languages loaded.
            (/usr/local/texlive/2014/texmf-dist/tex/latex/base/article.cls
            Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
            (/usr/local/texlive/2014/texmf-dist/tex/latex/base/size10.clo))
            (/usr/local/texlive/2014/texmf-dist/tex/latex/tools/multicol.sty)
            (./wi1_la_tab.aux)
            
            ! LaTeX Error: Can be used only in preamble.
            
            See the LaTeX manual or LaTeX Companion for explanation.
            Type  H <return>  for immediate help.
             ...                                              
                                                              
            l.6 \documentclass
                              {article}
            ?
            ! Emergency stop.
             ...                                              
                                                              
            l.6 \documentclass
                              {article}
            !  ==> Fatal error occurred, no output PDF file produced!
            Transcript written on wi1_la_tab.log.
            Collected error summary (may duplicate other messages):
              pdflatex: Command for 'pdflatex' gave return code 256
            Latexmk: Use the -f option to force complete processing,
             unless error was exceeding maximum runs of latex/pdflatex.
            Latexmk: Errors, so I did not complete making targets
            Survey results being calculated
            Kind regards,
            Konrad
            Version: Stata/IC 13.1

            Comment


            • #7
              I think I see the problem. Remove the option “body” from the tabout command. That option is an alternative to using topf and botf. Your current code has a header from topf, followed by a header from body. Latexmk is telling you that you can't call \documentclass{article} twice (“Can be used only in preamble”). For future reference, the contents of the produced LaTeX file might have been useful to diagnose the problem.

              Comment


              • #8
                Thank you very much.
                Kind regards,
                Konrad
                Version: Stata/IC 13.1

                Comment

                Working...
                X