Creates a LaTeX `\\input{}` or an RST '.. literalinclude:: ' command for including a netlist file. :param netlistFile: Name of the netlist file relative to the project circuit directory :type netlistFile: str :param lineRange: range of lines
(self, netlistFile, lineRange=None, firstNumber=None)
| 28 | self.snippet = None |
| 29 | |
| 30 | def netlist(self, netlistFile, lineRange=None, firstNumber=None): |
| 31 | """ |
| 32 | Creates a LaTeX `\\input{}` or an RST '.. literalinclude:: ' |
| 33 | command for including a netlist file. |
| 34 | |
| 35 | :param netlistFile: Name of the netlist file relative to the project circuit directory |
| 36 | :type netlistFile: str |
| 37 | |
| 38 | :param lineRange: range of lines to be included |
| 39 | :type lineRange: str |
| 40 | |
| 41 | :param firstNumber: start number of the displayed line numbers |
| 42 | :type firstNumber: str |
| 43 | |
| 44 | :return: SLiCAP Snippet object |
| 45 | :rtype: SLiCAP.SLiCAPprotos.Snippet |
| 46 | |
| 47 | :example: latex |
| 48 | |
| 49 | >>> import SLiCAP as sl |
| 50 | >>> ltx = sl.LaTeXformatter() # Creates a LaTeX formatter |
| 51 | >>> latex_netlist = ltx.netlist("myFirstRCnetwork.cir") |
| 52 | >>> latex_netlist.save("netlist") |
| 53 | |
| 54 | This will save a file `netlist.tex` in the `sl.ini.tex_snippets` folder |
| 55 | with the following contents: |
| 56 | |
| 57 | .. code:: |
| 58 | |
| 59 | \\textbf{Netlist: myFirstRCnetwork.cir} |
| 60 | \\lstinputlisting[language=ltspice, numbers=left]{<full path to myFirstRCnetwork.cir>} |
| 61 | |
| 62 | The netlist file is assumed to reside in the folder given by `sl.ini.cir_path`. |
| 63 | If you want to include a file from any other location, use: |
| 64 | |
| 65 | >>> ltx.file() |
| 66 | """ |
| 67 | netlistFile = netlistFile.replace("_", "\\_") |
| 68 | TEX = '\\textbf{Netlist: ' + netlistFile + '}\n\n' |
| 69 | TEX += '\\lstinputlisting[language=ltspice, numbers=left' |
| 70 | if lineRange != None: |
| 71 | TEX += ', linerange={' + lineRange + '}' |
| 72 | if firstNumber != None: |
| 73 | TEX += ', firstnumber=' + str(int(firstNumber)) |
| 74 | TEX += ']{' + ini.project_path + ini.cir_path + netlistFile + '}\n\n' |
| 75 | |
| 76 | return Snippet(TEX, self.format) |
| 77 | |
| 78 | def elementData(self, circuitObject, label="", caption="", |
| 79 | color="myyellow"): |