如何在PowerShell管道中处理latex / tikz-timing图表?

时间:2015-03-28 20:23:16

标签: powershell latex pipeline pdflatex tikz

我有几个tikz-timing图,我用包装器乳胶文件编译。这个包装器使用独立的latex包来生成pdf和png文件。我想节省所有这些包装文件,只用一个替换它们。另外,我想将一个文件名列表输入到PowerShell函数中,该函数处理每个波形tex文件,它是一般的包装文件。

I uploaded all files to Gist.

更详细:

Waveform.tex是包装器tex文件,它在\input{...}宏中有一个占位符。此占位符由PowerShell脚本替换。

\documentclass[convert={density=600,size=2000x800,outext=.png}]{standalone}

\usepackage[utf8]{inputenc}              % UTF-8 tex file input incoding
\usepackage[T1]{fontenc}                 % Type1 font encoding
\usepackage[ngerman]{babel}              % new german writing rules; must be loaded before microtype
\usepackage{courier}                            % set courier font as default for teletype writer (texttt, ttfamily, ...)
\usepackage[usenames,svgnames,table]{xcolor}    % load colors and color-names

\usepackage{pgf}                    % primitive drawing library
\usepackage{tikz}                   % PGF frontend, drawing macros
\usepackage{tikz-timing}            % spezial TikZ library for waveform/timing diagrams
  \usetikztiminglibrary{nicetabs}         %  sublibrary for better looking timingtables

\begin{document}
  \input{%%WaveformFile%%}
  %\input{IICController}    % uncomment this if timing-diagram is a fixed file name
\end{document}

IICController.tex是示例波形:

%
\tikztimingmetachar{A}[1]{#1{Z[black]};}
%
\begin{tikztimingtable}[
  timing/table/header/.style={font=\bf},
  timing/wscale=2,
  timing/nice tabs,
]
Master\_BusRequest  & L H H  4H 4H 4H 4H  L  \\
Master\_BusGrant  & L L H  4H 4H 4H 4H  L  \\
Master\_BusAbort  & L L L 4L 4L 4L 4L L  \\
Master\_WP\_Valid  & L L L 4H 4H 4H 4H L  \\
Master\_WP\_Data  & A A A 4D{Phy Adr + R/W} 4D{Reg Adr} 4D{D0.0} 4D{D0.1} A \\
Master\_WP\_Last  & L L L 4L 4L 4L 4H L  \\
Master\_WP\_Ack    & L L L 3LH 3LH 3LH 3LH L  \\
\extracode
  \tableheader{Signalname}{Signalverlauf}
  \tablerules
  \begin{background}[shift={(0.1,0)},help lines]
    \vertlines{0,2,...,40}
  \end{background}
\end{tikztimingtable}

最后,这是我的PowerShell脚本:

function Compile-Waveform
  { [CmdletBinding()]Param(
      [Parameter(
        Mandatory=$True,
        Position=0,
        ValueFromPipeline=$true,
        ValueFromPipelineByPropertyName=$true)]
      [String[]]$InputFiles
    )
    Begin
      { $WrapperFile    = "Waveform.tex"
        $WrapperContent = Get-Content -Path $WrapperFile -Encoding ASCII -Raw
      }
    Process
      { #Write-Host "WrapperContent" -ForegroundColor Green
        #Write-Host $WrapperContent -ForegroundColor Gray
        #Write-Host ""

        foreach($InputFile in $InputFiles)
          { Write-Host "processing file: '$Inputfile'" -ForegroundColor Yellow
            $OutputFile = [String]$InputFile.Replace(".tex", ".png")
            $Temp = $WrapperContent -replace "%%WaveformFile%%",$InputFile

            #Write-Host "Temp" -ForegroundColor Green
            #Write-Host $Temp -ForegroundColor Gray
            #Write-Host ""

            Write-Output $Temp | & 'C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe' -shell-escape -time-statistics -synctex=1 -interaction=nonstopmode
          }
      }
  }

如何使用脚本?

导航到IICController.tex的文件夹。获取* .ps1文件,最后将所有找到的波形文件传输到PowerShell函数中:

cd d:\temp\waveform
. compile.ps1
dir IICController.tex | Compile-Waveform

现在pdflatex将打印错误日志:

processing file: 'D:\git\SATAController\doc\Waveforms\Simple.tex'
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (MiKTeX 2.9 64-bit)
**entering extended mode
LaTeX2e <2014/05/01>
Babel <3.9l> and hyphenation patterns for 68 languages loaded.
! Emergency stop.
<*> ...600,size=2000x800,outext=.png}]{standalone}

!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on texput.log.
gross execution time: 26 ms
user mode: 0 ms, kernel mode: 15 ms, total: 15

puttex.log与控制台输出具有相同的内容。

有谁知道发生了什么?

如果我在PowerShell中使用固定文件名运行Wavefom.tex(请参阅第二行\input行),一切正常。

0 个答案:

没有答案