Skip to content

Commit

Permalink
Tidy latex simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
mph- committed Aug 13, 2024
1 parent 2a30435 commit 976686a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion lcapy/engformatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def _fmt(self, valstr, unit='', prefix='', aslatex=True):
s += '\\mu\\mathrm{' + unit + '}'
else:
if unit.startswith('$'):
s += '\\mathrm{' + prefix + '}' + unit[1:-1]
if prefix == '':
s += unit[1:-1]
else:
s += '\\mathrm{' + prefix + '}' + unit[1:-1]
else:
s += '\\mathrm{' + prefix + unit + '}'
return s
Expand Down
10 changes: 5 additions & 5 deletions lcapy/tests/test_schematic.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def test_schematic1(self):
\coordinate (2) at (2,0);
\coordinate (3) at (2.5,0);
\coordinate (0) at (4.5,0);
\draw (1) to [R, l_=$1\,\mbox{$\Omega$}$, n=R1] (2);
\draw (1) to [R, l_=$1\,\Omega$, n=R1] (2);
\draw[-] (2) to [short, n=Wanon1] (3);
\draw (3) to [C, l_=$2\,\mbox{F}$, n=C1] (0);
\draw (3) to [C, l_=$2\,\mathrm{F}$, n=C1] (0);
\draw (1) node[ocirc] {};
\draw (0) node[ocirc] {};
\end{tikzpicture}
Expand Down Expand Up @@ -54,9 +54,9 @@ def test_schematic2(self):
\coordinate (1) at (0,0);
\coordinate (2) at (2,0);
\coordinate (3) at (4,0);
\draw (1) to [R, l_={$R_{1}$=$1\,\mbox{$\Omega$}$}, n=R1] (2);
\draw (2) to [R, l_={$R_{2}$=$2\,\mbox{$\Omega$}$}, n=R2] (3);
\draw (1) to [C, l_={$C$=$3\,\mbox{F}$}, n=C] (3);
\draw (1) to [R, l_={$R_{1}$=$1\,\Omega$}, n=R1] (2);
\draw (2) to [R, l_={$R_{2}$=$2\,\Omega$}, n=R2] (3);
\draw (1) to [C, l_={$C$=$3\,\mathrm{F}$}, n=C] (3);
\draw (1) node[circ] {};
\draw (2) node[circ] {};
\draw (3) node[circ] {};
Expand Down

0 comments on commit 976686a

Please sign in to comment.