0

I get error messages that don't make sense running code which I've adapted from https://ftp.acc.umu.se/mirror/CTAN/graphics/circuit_macros/doc/Circuit_macros.pdf. I've rewritten the code with the built-in text editor in Ubuntu the "Text Editor" to be sure that I don't have hidden tokens from the copy/paste process and I have no tabs in the file. It worked once, don't know how. Should I re-install TexLive? I've been running other Tikz stuff with no problem.

LaTeX Warning: Writing file `./['.

LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help.

l.4 \begin{filecontents*}[n

                       oheader,force]{sample.m4}

When I rerun it I get the same missing \begin{document}complaint and it always error indicates the options bracket in \filecontents. If I delete the offending option it complains about the next. It also gives me a warning:

LaTeX Warning: File `[' already exists on the system. Not generating it from this source.

\documentclass{article}
\usepackage{tikz}
\newcommand\mtotex[2]{\immediate\write18{m4 #2.m4 | dpic -#1 > #2.tex}}
\begin{filecontents*}[noheader,force]{sample1.m4}
include(pgf.m4)
.PS
cct_init
elen = 0.75
Origin: Here
    source(up_ elen); llabel(-,v_s,+)
    resistor(right_ elen); rlabel(,R,)
    dot
    {  
        capacitor(down_ to (Here,Origin))
        rlabel(+,v,-);llabel(,C,)
        dot
    }
    line right_ elen*3/3
    inductor(down_ Here.y-Origin.y); rlabel(,L,);b_current(i)
    line to Origin
.PE
\end{filecontents}
\begin{filecontents}[overwrite,noheader,nosearch]{dummy.m4}
\end{filecontents}

\begin{document} \mtotex{g}{sample1} \begin{figure}[ht] \input{sample} \caption{customized caption} \label{Symbolic_label} \end{figure} \end{document}```

Bernard
  • 271,350
  • 2
    What is the output of pdflatex '\stop'? You probably has an older version of LaTeX that doesn't support the optional argument in filecontents – Phelype Oleinik May 16 '22 at 20:45
  • pdflatex '\stop' This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode LaTeX2e <2017-04-15> Babel <3.18> and hyphenation patterns for 84 language(s) loaded. No pages of output. Transcript written on texput.log. – Lasse Karagiannis May 17 '22 at 03:19
  • 1
    The options to filecontents were introduced in 2019-10-01, so your version of LaTeX doesn't support them. You need to update (or use the filecontents package and \begin{filecontents*}, to get the same behaviour as [noheader,force]). – Phelype Oleinik May 17 '22 at 10:31
  • @PhelypeOleinik You were right. Reinstalled. Now it complains
    (./testQ.aux)
    (/usr/local/texlive/2022/texmf-dist/tex/context/sample/common/sample.tex
    ! Undefined control sequence.
    l.4 \starttext ```
              It came when I changed
    ```\begin{filecontents*}[noheader,force]{sample1.m4}```
    to ```\begin{filecontents}[overwrite,noheader,nosearch]{sample1.m4}``` I had error:
    ```)
    Runaway argument?
    ! File ended while scanning use of ^^M.
    <inserted text> 
                    \par
    
    – Lasse Karagiannis May 18 '22 at 12:07
  • 1
    You seem to be executing a ConTeXt example file context/sample/common/sample.tex. That won't work in LaTeX... – Phelype Oleinik May 19 '22 at 10:27
  • Thank you @PhelypeOleinik . It works! You're amazing! I had a typo. Should have done input on sample1.tex and not sample,tex which u say belongs to ConTeX. Don't know how I got ConTeX on my computer, as far as I know I've only installed TexLive Then I forgot --shell-escape a couple of times. pdflatex --shell-escape testQ.tex – Lasse Karagiannis May 19 '22 at 18:15

0 Answers0