How do I customize Circuit_macros in listings? The Next CEO of Stack Overflowadvanced string...

How to get the last not-null value in an ordered column of a huge table?

How can the PCs determine if an item is a phylactery?

Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?

Towers in the ocean; How deep can they be built?

How can I make proper oatmeal cookies?

Is it professional to write unrelated content in an almost-empty email?

If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?

Does higher Oxidation/ reduction potential translate to higher energy storage in battery?

What are the unusually-enlarged wing sections on this P-38 Lightning?

Man transported from Alternate World into ours by a Neutrino Detector

Ising model simulation

Point distance program written without a framework

Could a dragon use its wings to swim?

TikZ: How to fill area with a special pattern?

Is fine stranded wire ok for main supply line?

Can Sneak Attack be used when hitting with an improvised weapon?

Is it correct to say moon starry nights?

Is it ever safe to open a suspicious HTML file (e.g. email attachment)?

Defamation due to breach of confidentiality

Is there a way to save my career from absolute disaster?

Aggressive Under-Indexing and no data for missing index

Airplane gently rocking its wings during whole flight

Spaces in which all closed sets are regular closed

What flight has the highest ratio of timezone difference to flight time?



How do I customize Circuit_macros in listings?



The Next CEO of Stack Overflowadvanced string highlighting in listingsColored strings by listings packageHow do I customize a LuaLaTeX cmap?How can I highlight an interactive GAP session just like so?Issues using listings packageFailure After Using Latexdiff Script: latexdiff marking up lstlisting environmentHow can I avoid the use of default styles when no listings language is set?Highlighting hex in listingsmultiple classes not working with otherkeywords in listings packagelstnewenvironment/lstset : using colors conditionally emph/emphstyle - SAS: (in=_x) versus if x in (1,2)Color delimiters in listings differently from content












2















MWE;



documentclass{article}
usepackage{xcolor}
usepackage{listings}
definecolor{Others}{RGB}{0,110,40} % Green
definecolor{Character}{RGB}{146,76,157} % Purple
definecolor{Number}{RGB}{176,128,0} % Brown

lstdefinestyle{circuit_macros}
{
basicstyle=scriptsizettfamilynull,
literate=*{0}{{textcolor{Number}{0}}}{1}%
{1}{{textcolor{Number}{1}}}{1}%
{2}{{textcolor{Number}{2}}}{1}%
{3}{{textcolor{Number}{3}}}{1}%
{4}{{textcolor{Number}{4}}}{1}%
{5}{{textcolor{Number}{5}}}{1}%
{6}{{textcolor{Number}{6}}}{1}%
{7}{{textcolor{Number}{7}}}{1}%
{8}{{textcolor{Number}{8}}}{1}%
{9}{{textcolor{Number}{9}}}{1}%
{.0}{{textcolor{Number}{.0}}}{1}%
{.1}{{color{Number}{.1}}}{1}%
{.2}{{color{Number}{.2}}}{1}%
{.3}{{color{Number}{.3}}}{1}%
{.4}{{color{Number}{.4}}}{1}%
{.5}{{color{Number}{.5}}}{1}%
{.6}{{color{Number}{.6}}}{1}%
{.7}{{color{Number}{.7}}}{1}%
{.8}{{color{Number}{.8}}}{1}%
{.9}{{color{Number}{.9}}}{1}%
{(}{{color{Character}{(}}}{1}%
{)}{{color{Character}{)}}}{1}%
{/}{{color{black}{/}}}{1}%
{:}{{color{Character}{:}}}{1}%
{;}{{color{black}{;}}}{1}%
{,}{{color{black}{,}}}{1}%
{.}{{color{black}{.}}}{1}%
{(}{{color{Character}{(}}}{1}%
{)}{{color{Character}{)}}}{1}%
,
morekeywords={In1,In2,In3},
keywordstyle=color{black},
morekeywords=[2]{scale,above,with,at,Here,line,to,end,start,from,ljust},
keywordstyle=[2]{bfcolor{black}},
morekeywords=[3]{PS,PE},
keywordstyle=[3]{color{Character}},
morekeywords=[4]{corner,Out,In1,In2,In3,In4},
keywordstyle=[4]{color{black}},
morekeywords=[5]{down_,up_,elen_,right_,log_init,NOT_gate,dot,AND_gate,OR_gate},
keywordstyle=[5]color{Others},
sensitive=false,
comment=[l][color{gray}]{#},
string=[b]",
stringstyle=color{red},
}

begin{document}

begin{lstlisting}[style=circuit_macros]
% `logic.cir'

.PS

scale=25.4
log_init

#setrgb(0,0,1) # Blue Color
#dot(,,1)

O:(0,0)

"A" at Here above;DA:dot(,,1);
line down_ elen_/2 with .start at DA.s;dot;{A:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LA:line down_ to (Here.x,A.end.y);

"B" at (elen_,0) above;DB:dot(,,1);
line down_ elen_/2 with .start at DB.s;dot;{B:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LB:line to (Here.x,B.end.y);

"C" at (2*elen_,0) above;DC:dot(,,1);
line down_ elen_/2 with .start at DC.s;dot;{C:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LC:line to (Here.x,C.end.y);

right_

X1:AND_gate(2) at (3*elen_,LC.y+15)
line from X1.In1 to (LA.x,X1.In1.y);dot
line from X1.In2 to (LB.x,X1.In2.y);dot

X2:AND_gate(2) at (X1.x,X1.y-15);
line from X2.In1 to (LB.x,X2.In1.y);dot
line from X2.In2 to (C.x,X2.In2.y);dot

X3:AND_gate(3) at (X1.x,X1.y-30);
line from X3.In1 to (A.x,X3.In1.y);dot
line from X3.In2 to (B.x,X3.In2.y);dot
line from X3.In3 to (LC.x,X3.In3.y);dot

line right_ elen_ from X2.Out;X4:OR_gate(3) with .In2 at Here;
line right_ elen_/2 from X1.Out;corner;line down_ to (Here.x,X4.In1.y);corner;line to X4.In1
line right_ elen_/2 from X3.Out;corner;line up_ to (Here.x,X4.In3.y);corner;line to X4.In3

line right_ elen_/2 from X4.Out; "X" ljust;dot(,,1);

.PE
end{lstlisting}
end{document}


And output (Of course there are errors. This was what I could do.)



enter image description here



But original output



enter image description here



What I want to do;



1) codes with digits such as In1, In2 should be black.



2) at the end of the :or characters starting ; and ending : must be purple. Such as ;DA:, X1: written in source code. Other DA, X1 should be black.



3) When I copy and paste the output into the notebook, there is a space between characters. So when I paste it into its own program it gives an error.



enter image description here



Are these possible?



Related to: advanced string highlighting in listings










share|improve this question
















bumped to the homepage by Community 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Your questions seem to be responded explicitly in your MWE. Precisely, 1) your code is already doing so: morecomment=[l][color{gray}]{#},. 2) You can do the same case for ) as you have defined for " in morestring=[b]". I don't have a solution for your third question. For 4, what about defining a new array like morekeywords and then set a colour for?

    – Sina Ahmadi
    Feb 21 at 1:56











  • I will check...

    – Özgür
    Feb 23 at 1:26


















2















MWE;



documentclass{article}
usepackage{xcolor}
usepackage{listings}
definecolor{Others}{RGB}{0,110,40} % Green
definecolor{Character}{RGB}{146,76,157} % Purple
definecolor{Number}{RGB}{176,128,0} % Brown

lstdefinestyle{circuit_macros}
{
basicstyle=scriptsizettfamilynull,
literate=*{0}{{textcolor{Number}{0}}}{1}%
{1}{{textcolor{Number}{1}}}{1}%
{2}{{textcolor{Number}{2}}}{1}%
{3}{{textcolor{Number}{3}}}{1}%
{4}{{textcolor{Number}{4}}}{1}%
{5}{{textcolor{Number}{5}}}{1}%
{6}{{textcolor{Number}{6}}}{1}%
{7}{{textcolor{Number}{7}}}{1}%
{8}{{textcolor{Number}{8}}}{1}%
{9}{{textcolor{Number}{9}}}{1}%
{.0}{{textcolor{Number}{.0}}}{1}%
{.1}{{color{Number}{.1}}}{1}%
{.2}{{color{Number}{.2}}}{1}%
{.3}{{color{Number}{.3}}}{1}%
{.4}{{color{Number}{.4}}}{1}%
{.5}{{color{Number}{.5}}}{1}%
{.6}{{color{Number}{.6}}}{1}%
{.7}{{color{Number}{.7}}}{1}%
{.8}{{color{Number}{.8}}}{1}%
{.9}{{color{Number}{.9}}}{1}%
{(}{{color{Character}{(}}}{1}%
{)}{{color{Character}{)}}}{1}%
{/}{{color{black}{/}}}{1}%
{:}{{color{Character}{:}}}{1}%
{;}{{color{black}{;}}}{1}%
{,}{{color{black}{,}}}{1}%
{.}{{color{black}{.}}}{1}%
{(}{{color{Character}{(}}}{1}%
{)}{{color{Character}{)}}}{1}%
,
morekeywords={In1,In2,In3},
keywordstyle=color{black},
morekeywords=[2]{scale,above,with,at,Here,line,to,end,start,from,ljust},
keywordstyle=[2]{bfcolor{black}},
morekeywords=[3]{PS,PE},
keywordstyle=[3]{color{Character}},
morekeywords=[4]{corner,Out,In1,In2,In3,In4},
keywordstyle=[4]{color{black}},
morekeywords=[5]{down_,up_,elen_,right_,log_init,NOT_gate,dot,AND_gate,OR_gate},
keywordstyle=[5]color{Others},
sensitive=false,
comment=[l][color{gray}]{#},
string=[b]",
stringstyle=color{red},
}

begin{document}

begin{lstlisting}[style=circuit_macros]
% `logic.cir'

.PS

scale=25.4
log_init

#setrgb(0,0,1) # Blue Color
#dot(,,1)

O:(0,0)

"A" at Here above;DA:dot(,,1);
line down_ elen_/2 with .start at DA.s;dot;{A:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LA:line down_ to (Here.x,A.end.y);

"B" at (elen_,0) above;DB:dot(,,1);
line down_ elen_/2 with .start at DB.s;dot;{B:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LB:line to (Here.x,B.end.y);

"C" at (2*elen_,0) above;DC:dot(,,1);
line down_ elen_/2 with .start at DC.s;dot;{C:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LC:line to (Here.x,C.end.y);

right_

X1:AND_gate(2) at (3*elen_,LC.y+15)
line from X1.In1 to (LA.x,X1.In1.y);dot
line from X1.In2 to (LB.x,X1.In2.y);dot

X2:AND_gate(2) at (X1.x,X1.y-15);
line from X2.In1 to (LB.x,X2.In1.y);dot
line from X2.In2 to (C.x,X2.In2.y);dot

X3:AND_gate(3) at (X1.x,X1.y-30);
line from X3.In1 to (A.x,X3.In1.y);dot
line from X3.In2 to (B.x,X3.In2.y);dot
line from X3.In3 to (LC.x,X3.In3.y);dot

line right_ elen_ from X2.Out;X4:OR_gate(3) with .In2 at Here;
line right_ elen_/2 from X1.Out;corner;line down_ to (Here.x,X4.In1.y);corner;line to X4.In1
line right_ elen_/2 from X3.Out;corner;line up_ to (Here.x,X4.In3.y);corner;line to X4.In3

line right_ elen_/2 from X4.Out; "X" ljust;dot(,,1);

.PE
end{lstlisting}
end{document}


And output (Of course there are errors. This was what I could do.)



enter image description here



But original output



enter image description here



What I want to do;



1) codes with digits such as In1, In2 should be black.



2) at the end of the :or characters starting ; and ending : must be purple. Such as ;DA:, X1: written in source code. Other DA, X1 should be black.



3) When I copy and paste the output into the notebook, there is a space between characters. So when I paste it into its own program it gives an error.



enter image description here



Are these possible?



Related to: advanced string highlighting in listings










share|improve this question
















bumped to the homepage by Community 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Your questions seem to be responded explicitly in your MWE. Precisely, 1) your code is already doing so: morecomment=[l][color{gray}]{#},. 2) You can do the same case for ) as you have defined for " in morestring=[b]". I don't have a solution for your third question. For 4, what about defining a new array like morekeywords and then set a colour for?

    – Sina Ahmadi
    Feb 21 at 1:56











  • I will check...

    – Özgür
    Feb 23 at 1:26
















2












2








2








MWE;



documentclass{article}
usepackage{xcolor}
usepackage{listings}
definecolor{Others}{RGB}{0,110,40} % Green
definecolor{Character}{RGB}{146,76,157} % Purple
definecolor{Number}{RGB}{176,128,0} % Brown

lstdefinestyle{circuit_macros}
{
basicstyle=scriptsizettfamilynull,
literate=*{0}{{textcolor{Number}{0}}}{1}%
{1}{{textcolor{Number}{1}}}{1}%
{2}{{textcolor{Number}{2}}}{1}%
{3}{{textcolor{Number}{3}}}{1}%
{4}{{textcolor{Number}{4}}}{1}%
{5}{{textcolor{Number}{5}}}{1}%
{6}{{textcolor{Number}{6}}}{1}%
{7}{{textcolor{Number}{7}}}{1}%
{8}{{textcolor{Number}{8}}}{1}%
{9}{{textcolor{Number}{9}}}{1}%
{.0}{{textcolor{Number}{.0}}}{1}%
{.1}{{color{Number}{.1}}}{1}%
{.2}{{color{Number}{.2}}}{1}%
{.3}{{color{Number}{.3}}}{1}%
{.4}{{color{Number}{.4}}}{1}%
{.5}{{color{Number}{.5}}}{1}%
{.6}{{color{Number}{.6}}}{1}%
{.7}{{color{Number}{.7}}}{1}%
{.8}{{color{Number}{.8}}}{1}%
{.9}{{color{Number}{.9}}}{1}%
{(}{{color{Character}{(}}}{1}%
{)}{{color{Character}{)}}}{1}%
{/}{{color{black}{/}}}{1}%
{:}{{color{Character}{:}}}{1}%
{;}{{color{black}{;}}}{1}%
{,}{{color{black}{,}}}{1}%
{.}{{color{black}{.}}}{1}%
{(}{{color{Character}{(}}}{1}%
{)}{{color{Character}{)}}}{1}%
,
morekeywords={In1,In2,In3},
keywordstyle=color{black},
morekeywords=[2]{scale,above,with,at,Here,line,to,end,start,from,ljust},
keywordstyle=[2]{bfcolor{black}},
morekeywords=[3]{PS,PE},
keywordstyle=[3]{color{Character}},
morekeywords=[4]{corner,Out,In1,In2,In3,In4},
keywordstyle=[4]{color{black}},
morekeywords=[5]{down_,up_,elen_,right_,log_init,NOT_gate,dot,AND_gate,OR_gate},
keywordstyle=[5]color{Others},
sensitive=false,
comment=[l][color{gray}]{#},
string=[b]",
stringstyle=color{red},
}

begin{document}

begin{lstlisting}[style=circuit_macros]
% `logic.cir'

.PS

scale=25.4
log_init

#setrgb(0,0,1) # Blue Color
#dot(,,1)

O:(0,0)

"A" at Here above;DA:dot(,,1);
line down_ elen_/2 with .start at DA.s;dot;{A:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LA:line down_ to (Here.x,A.end.y);

"B" at (elen_,0) above;DB:dot(,,1);
line down_ elen_/2 with .start at DB.s;dot;{B:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LB:line to (Here.x,B.end.y);

"C" at (2*elen_,0) above;DC:dot(,,1);
line down_ elen_/2 with .start at DC.s;dot;{C:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LC:line to (Here.x,C.end.y);

right_

X1:AND_gate(2) at (3*elen_,LC.y+15)
line from X1.In1 to (LA.x,X1.In1.y);dot
line from X1.In2 to (LB.x,X1.In2.y);dot

X2:AND_gate(2) at (X1.x,X1.y-15);
line from X2.In1 to (LB.x,X2.In1.y);dot
line from X2.In2 to (C.x,X2.In2.y);dot

X3:AND_gate(3) at (X1.x,X1.y-30);
line from X3.In1 to (A.x,X3.In1.y);dot
line from X3.In2 to (B.x,X3.In2.y);dot
line from X3.In3 to (LC.x,X3.In3.y);dot

line right_ elen_ from X2.Out;X4:OR_gate(3) with .In2 at Here;
line right_ elen_/2 from X1.Out;corner;line down_ to (Here.x,X4.In1.y);corner;line to X4.In1
line right_ elen_/2 from X3.Out;corner;line up_ to (Here.x,X4.In3.y);corner;line to X4.In3

line right_ elen_/2 from X4.Out; "X" ljust;dot(,,1);

.PE
end{lstlisting}
end{document}


And output (Of course there are errors. This was what I could do.)



enter image description here



But original output



enter image description here



What I want to do;



1) codes with digits such as In1, In2 should be black.



2) at the end of the :or characters starting ; and ending : must be purple. Such as ;DA:, X1: written in source code. Other DA, X1 should be black.



3) When I copy and paste the output into the notebook, there is a space between characters. So when I paste it into its own program it gives an error.



enter image description here



Are these possible?



Related to: advanced string highlighting in listings










share|improve this question
















MWE;



documentclass{article}
usepackage{xcolor}
usepackage{listings}
definecolor{Others}{RGB}{0,110,40} % Green
definecolor{Character}{RGB}{146,76,157} % Purple
definecolor{Number}{RGB}{176,128,0} % Brown

lstdefinestyle{circuit_macros}
{
basicstyle=scriptsizettfamilynull,
literate=*{0}{{textcolor{Number}{0}}}{1}%
{1}{{textcolor{Number}{1}}}{1}%
{2}{{textcolor{Number}{2}}}{1}%
{3}{{textcolor{Number}{3}}}{1}%
{4}{{textcolor{Number}{4}}}{1}%
{5}{{textcolor{Number}{5}}}{1}%
{6}{{textcolor{Number}{6}}}{1}%
{7}{{textcolor{Number}{7}}}{1}%
{8}{{textcolor{Number}{8}}}{1}%
{9}{{textcolor{Number}{9}}}{1}%
{.0}{{textcolor{Number}{.0}}}{1}%
{.1}{{color{Number}{.1}}}{1}%
{.2}{{color{Number}{.2}}}{1}%
{.3}{{color{Number}{.3}}}{1}%
{.4}{{color{Number}{.4}}}{1}%
{.5}{{color{Number}{.5}}}{1}%
{.6}{{color{Number}{.6}}}{1}%
{.7}{{color{Number}{.7}}}{1}%
{.8}{{color{Number}{.8}}}{1}%
{.9}{{color{Number}{.9}}}{1}%
{(}{{color{Character}{(}}}{1}%
{)}{{color{Character}{)}}}{1}%
{/}{{color{black}{/}}}{1}%
{:}{{color{Character}{:}}}{1}%
{;}{{color{black}{;}}}{1}%
{,}{{color{black}{,}}}{1}%
{.}{{color{black}{.}}}{1}%
{(}{{color{Character}{(}}}{1}%
{)}{{color{Character}{)}}}{1}%
,
morekeywords={In1,In2,In3},
keywordstyle=color{black},
morekeywords=[2]{scale,above,with,at,Here,line,to,end,start,from,ljust},
keywordstyle=[2]{bfcolor{black}},
morekeywords=[3]{PS,PE},
keywordstyle=[3]{color{Character}},
morekeywords=[4]{corner,Out,In1,In2,In3,In4},
keywordstyle=[4]{color{black}},
morekeywords=[5]{down_,up_,elen_,right_,log_init,NOT_gate,dot,AND_gate,OR_gate},
keywordstyle=[5]color{Others},
sensitive=false,
comment=[l][color{gray}]{#},
string=[b]",
stringstyle=color{red},
}

begin{document}

begin{lstlisting}[style=circuit_macros]
% `logic.cir'

.PS

scale=25.4
log_init

#setrgb(0,0,1) # Blue Color
#dot(,,1)

O:(0,0)

"A" at Here above;DA:dot(,,1);
line down_ elen_/2 with .start at DA.s;dot;{A:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LA:line down_ to (Here.x,A.end.y);

"B" at (elen_,0) above;DB:dot(,,1);
line down_ elen_/2 with .start at DB.s;dot;{B:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LB:line to (Here.x,B.end.y);

"C" at (2*elen_,0) above;DC:dot(,,1);
line down_ elen_/2 with .start at DC.s;dot;{C:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LC:line to (Here.x,C.end.y);

right_

X1:AND_gate(2) at (3*elen_,LC.y+15)
line from X1.In1 to (LA.x,X1.In1.y);dot
line from X1.In2 to (LB.x,X1.In2.y);dot

X2:AND_gate(2) at (X1.x,X1.y-15);
line from X2.In1 to (LB.x,X2.In1.y);dot
line from X2.In2 to (C.x,X2.In2.y);dot

X3:AND_gate(3) at (X1.x,X1.y-30);
line from X3.In1 to (A.x,X3.In1.y);dot
line from X3.In2 to (B.x,X3.In2.y);dot
line from X3.In3 to (LC.x,X3.In3.y);dot

line right_ elen_ from X2.Out;X4:OR_gate(3) with .In2 at Here;
line right_ elen_/2 from X1.Out;corner;line down_ to (Here.x,X4.In1.y);corner;line to X4.In1
line right_ elen_/2 from X3.Out;corner;line up_ to (Here.x,X4.In3.y);corner;line to X4.In3

line right_ elen_/2 from X4.Out; "X" ljust;dot(,,1);

.PE
end{lstlisting}
end{document}


And output (Of course there are errors. This was what I could do.)



enter image description here



But original output



enter image description here



What I want to do;



1) codes with digits such as In1, In2 should be black.



2) at the end of the :or characters starting ; and ending : must be purple. Such as ;DA:, X1: written in source code. Other DA, X1 should be black.



3) When I copy and paste the output into the notebook, there is a space between characters. So when I paste it into its own program it gives an error.



enter image description here



Are these possible?



Related to: advanced string highlighting in listings







macros color listings languages






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 23 at 2:07







Özgür

















asked Feb 21 at 1:40









ÖzgürÖzgür

1,4611020




1,4611020





bumped to the homepage by Community 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Your questions seem to be responded explicitly in your MWE. Precisely, 1) your code is already doing so: morecomment=[l][color{gray}]{#},. 2) You can do the same case for ) as you have defined for " in morestring=[b]". I don't have a solution for your third question. For 4, what about defining a new array like morekeywords and then set a colour for?

    – Sina Ahmadi
    Feb 21 at 1:56











  • I will check...

    – Özgür
    Feb 23 at 1:26





















  • Your questions seem to be responded explicitly in your MWE. Precisely, 1) your code is already doing so: morecomment=[l][color{gray}]{#},. 2) You can do the same case for ) as you have defined for " in morestring=[b]". I don't have a solution for your third question. For 4, what about defining a new array like morekeywords and then set a colour for?

    – Sina Ahmadi
    Feb 21 at 1:56











  • I will check...

    – Özgür
    Feb 23 at 1:26



















Your questions seem to be responded explicitly in your MWE. Precisely, 1) your code is already doing so: morecomment=[l][color{gray}]{#},. 2) You can do the same case for ) as you have defined for " in morestring=[b]". I don't have a solution for your third question. For 4, what about defining a new array like morekeywords and then set a colour for?

– Sina Ahmadi
Feb 21 at 1:56





Your questions seem to be responded explicitly in your MWE. Precisely, 1) your code is already doing so: morecomment=[l][color{gray}]{#},. 2) You can do the same case for ) as you have defined for " in morestring=[b]". I don't have a solution for your third question. For 4, what about defining a new array like morekeywords and then set a colour for?

– Sina Ahmadi
Feb 21 at 1:56













I will check...

– Özgür
Feb 23 at 1:26







I will check...

– Özgür
Feb 23 at 1:26












1 Answer
1






active

oldest

votes


















0














enter image description here



enter image description here



documentclass[a4paper,11pt]{article}
%documentclass[a4paper,11pt]{standalone}% for demontration only!
usepackage[top=0.75in, bottom=0.75in, left=0.75in, right=0.75in]{geometry}
%usepackage{showframe}% for demontration only!
pagestyle{empty}
usepackage{xcolor}
usepackage{listings}

definecolor{Others}{RGB}{0,110,40} % Green
definecolor{Character}{RGB}{146,76,157} % Purple
definecolor{Number}{RGB}{176,128,0} % Brown

lstdefinestyle{circuit_macros}
{
basicstyle=scriptsizettfamilynull,
literate=*{,}{{color{black}{,}}}1%
0{{textcolor{Number}0}}1%
1{{textcolor{Number}1}}1%
2{{textcolor{Number}2}}1%
3{{textcolor{Number}3}}1%
4{{textcolor{Number}4}}1%
5{{textcolor{Number}5}}1%
6{{textcolor{Number}6}}1%
7{{textcolor{Number}7}}1%
8{{textcolor{Number}8}}1%
9{{textcolor{Number}9}}1%
({{color{Character}{(}}}1%
){{color{Character}{)}}}1%
/{{color{black}{/}}}1%
:{{color{Character}{:}}}1%
;{{color{black}{;}}}1%
.{{color{black}{.}}}1%
({{color{Character}{(}}}1%
{.0}{{textcolor{Number}{.0}}}1%
{.1}{{color{Number}{.1}}}1%
{.2}{{color{Number}{.2}}}1%
{.3}{{color{Number}{.3}}}1%
{.4}{{color{Number}{.4}}}1%
{.5}{{color{Number}{.5}}}1%
{.6}{{color{Number}{.6}}}1%
{.7}{{color{Number}{.7}}}1%
{.8}{{color{Number}{.8}}}1%
{.9}{{color{Number}{.9}}}1%
%
*{{color{black}{*}}}2%
{O:}{{color{Character}{O:}}}2%
{A.}{{color{black}{A.}}}2%
{B.}{{color{black}{B.}}}2%
{C.}{{color{black}{C.}}}2%
{A:}{{color{Character}{A:}}}2%
{B:}{{color{Character}{B:}}}2%
{C:}{{color{Character}{C:}}}2%
{DA:}{{color{Character}{DA:}}}3%
{DB:}{{color{Character}{DB:}}}3%
{DC:}{{color{Character}{DC:}}}3%
{LA.}{{color{black}{LA.}}}3%
{LB.}{{color{black}{LB.}}}3%
{LC.}{{color{black}{LC.}}}3%
{LA:}{{color{Character}{LA:}}}3%
{LB:}{{color{Character}{LB:}}}3%
{LC:}{{color{Character}{LC:}}}3%
{X1}{{color{black}{X1}}}2%
{X1:}{{color{Character}{X1:}}}3%
{X2}{{color{black}{X2:}}}2%
{X2:}{{color{Character}{X2:}}}3%
{X3}{{color{black}{X3:}}}2%
{X3:}{{color{Character}{X3:}}}3%
{X4}{{color{black}{X4:}}}2%
{X4:}{{color{Character}{X4:}}}3%
{"A"}{{bfcolor{red}{"A"}}}3%
{"B"}{{bfcolor{red}{"B"}}}3%
{"C"}{{bfcolor{red}{"C"}}}3%
{"X"}{{color{red}{"X"}}}3%
{In1}{{color{black}{In1}}}3%
{In2}{{color{black}{In2}}}3%
{In3}{{color{black}{In3}}}3%
{In4}{{color{black}{In4}}}3%
,
emph={scale,above,with,at,Here,line,to,end,start,from,ljust},
emphstyle={bfcolor{black}},
morekeywords=[3]{PS,PE},
keywordstyle=[3]{color{Character}},
morekeywords=[5]{down_,up_,elen_,right_,log_init,NOT_gate,dot,AND_gate,OR_gate},
keywordstyle=[5]color{Others},
sensitive=false,
morecomment=[l][color{gray}]{#},
}

begin{document}

begin{lstlisting}[style=circuit_macros]
% `logic.cir'

.PS

scale=25.4
log_init

#setrgb(0,0,1) # Blue Color
#dot(,,1)

O:(0,0)

"A" at Here above;DA:dot(,,1);
line down_ elen_/2 with .start at DA.s;dot;{A:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LA:line down_ to (Here.x,A.end.y);

"B" at (elen_,0) above;DB:dot(,,1);
line down_ elen_/2 with .start at DB.s;dot;{B:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LB:line to (Here.x,B.end.y);

"C" at (2*elen_,0) above;DC:dot(,,1);
line down_ elen_/2 with .start at DC.s;dot;{C:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LC:line to (Here.x,C.end.y);

right_

X1:AND_gate(2) at (3*elen_,LC.y+15)
line from X1.In1 to (LA.x,X1.In1.y);dot
line from X1.In2 to (LB.x,X1.In2.y);dot

X2:AND_gate(2) at (X1.x,X1.y-15);
line from X2.In1 to (LB.x,X2.In1.y);dot
line from X2.In2 to (C.x,X2.In2.y);dot

X3:AND_gate(3) at (X1.x,X1.y-30);
line from X3.In1 to (A.x,X3.In1.y);dot
line from X3.In2 to (B.x,X3.In2.y);dot
line from X3.In3 to (LC.x,X3.In3.y);dot

line right_ elen_ from X2.Out;X4:OR_gate(3) with .In2 at Here;
line right_ elen_/2 from X1.Out;corner;line down_ to (Here.x,X4.In1.y);corner;line to X4.In1
line right_ elen_/2 from X3.Out;corner;line up_ to (Here.x,X4.In3.y);corner;line to X4.In3

line right_ elen_/2 from X4.Out; "X" ljust;dot(,,1);

.PE
end{lstlisting}
end{document}





share|improve this answer


























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475923%2fhow-do-i-customize-circuit-macros-in-listings%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    enter image description here



    enter image description here



    documentclass[a4paper,11pt]{article}
    %documentclass[a4paper,11pt]{standalone}% for demontration only!
    usepackage[top=0.75in, bottom=0.75in, left=0.75in, right=0.75in]{geometry}
    %usepackage{showframe}% for demontration only!
    pagestyle{empty}
    usepackage{xcolor}
    usepackage{listings}

    definecolor{Others}{RGB}{0,110,40} % Green
    definecolor{Character}{RGB}{146,76,157} % Purple
    definecolor{Number}{RGB}{176,128,0} % Brown

    lstdefinestyle{circuit_macros}
    {
    basicstyle=scriptsizettfamilynull,
    literate=*{,}{{color{black}{,}}}1%
    0{{textcolor{Number}0}}1%
    1{{textcolor{Number}1}}1%
    2{{textcolor{Number}2}}1%
    3{{textcolor{Number}3}}1%
    4{{textcolor{Number}4}}1%
    5{{textcolor{Number}5}}1%
    6{{textcolor{Number}6}}1%
    7{{textcolor{Number}7}}1%
    8{{textcolor{Number}8}}1%
    9{{textcolor{Number}9}}1%
    ({{color{Character}{(}}}1%
    ){{color{Character}{)}}}1%
    /{{color{black}{/}}}1%
    :{{color{Character}{:}}}1%
    ;{{color{black}{;}}}1%
    .{{color{black}{.}}}1%
    ({{color{Character}{(}}}1%
    {.0}{{textcolor{Number}{.0}}}1%
    {.1}{{color{Number}{.1}}}1%
    {.2}{{color{Number}{.2}}}1%
    {.3}{{color{Number}{.3}}}1%
    {.4}{{color{Number}{.4}}}1%
    {.5}{{color{Number}{.5}}}1%
    {.6}{{color{Number}{.6}}}1%
    {.7}{{color{Number}{.7}}}1%
    {.8}{{color{Number}{.8}}}1%
    {.9}{{color{Number}{.9}}}1%
    %
    *{{color{black}{*}}}2%
    {O:}{{color{Character}{O:}}}2%
    {A.}{{color{black}{A.}}}2%
    {B.}{{color{black}{B.}}}2%
    {C.}{{color{black}{C.}}}2%
    {A:}{{color{Character}{A:}}}2%
    {B:}{{color{Character}{B:}}}2%
    {C:}{{color{Character}{C:}}}2%
    {DA:}{{color{Character}{DA:}}}3%
    {DB:}{{color{Character}{DB:}}}3%
    {DC:}{{color{Character}{DC:}}}3%
    {LA.}{{color{black}{LA.}}}3%
    {LB.}{{color{black}{LB.}}}3%
    {LC.}{{color{black}{LC.}}}3%
    {LA:}{{color{Character}{LA:}}}3%
    {LB:}{{color{Character}{LB:}}}3%
    {LC:}{{color{Character}{LC:}}}3%
    {X1}{{color{black}{X1}}}2%
    {X1:}{{color{Character}{X1:}}}3%
    {X2}{{color{black}{X2:}}}2%
    {X2:}{{color{Character}{X2:}}}3%
    {X3}{{color{black}{X3:}}}2%
    {X3:}{{color{Character}{X3:}}}3%
    {X4}{{color{black}{X4:}}}2%
    {X4:}{{color{Character}{X4:}}}3%
    {"A"}{{bfcolor{red}{"A"}}}3%
    {"B"}{{bfcolor{red}{"B"}}}3%
    {"C"}{{bfcolor{red}{"C"}}}3%
    {"X"}{{color{red}{"X"}}}3%
    {In1}{{color{black}{In1}}}3%
    {In2}{{color{black}{In2}}}3%
    {In3}{{color{black}{In3}}}3%
    {In4}{{color{black}{In4}}}3%
    ,
    emph={scale,above,with,at,Here,line,to,end,start,from,ljust},
    emphstyle={bfcolor{black}},
    morekeywords=[3]{PS,PE},
    keywordstyle=[3]{color{Character}},
    morekeywords=[5]{down_,up_,elen_,right_,log_init,NOT_gate,dot,AND_gate,OR_gate},
    keywordstyle=[5]color{Others},
    sensitive=false,
    morecomment=[l][color{gray}]{#},
    }

    begin{document}

    begin{lstlisting}[style=circuit_macros]
    % `logic.cir'

    .PS

    scale=25.4
    log_init

    #setrgb(0,0,1) # Blue Color
    #dot(,,1)

    O:(0,0)

    "A" at Here above;DA:dot(,,1);
    line down_ elen_/2 with .start at DA.s;dot;{A:line down_ 3.5*elen_};line right_ elen_/2;corner;
    line down_ elen_/2;NOT_gate;LA:line down_ to (Here.x,A.end.y);

    "B" at (elen_,0) above;DB:dot(,,1);
    line down_ elen_/2 with .start at DB.s;dot;{B:line down_ 3.5*elen_};line right_ elen_/2;corner;
    line down_ elen_/2;NOT_gate;LB:line to (Here.x,B.end.y);

    "C" at (2*elen_,0) above;DC:dot(,,1);
    line down_ elen_/2 with .start at DC.s;dot;{C:line down_ 3.5*elen_};line right_ elen_/2;corner;
    line down_ elen_/2;NOT_gate;LC:line to (Here.x,C.end.y);

    right_

    X1:AND_gate(2) at (3*elen_,LC.y+15)
    line from X1.In1 to (LA.x,X1.In1.y);dot
    line from X1.In2 to (LB.x,X1.In2.y);dot

    X2:AND_gate(2) at (X1.x,X1.y-15);
    line from X2.In1 to (LB.x,X2.In1.y);dot
    line from X2.In2 to (C.x,X2.In2.y);dot

    X3:AND_gate(3) at (X1.x,X1.y-30);
    line from X3.In1 to (A.x,X3.In1.y);dot
    line from X3.In2 to (B.x,X3.In2.y);dot
    line from X3.In3 to (LC.x,X3.In3.y);dot

    line right_ elen_ from X2.Out;X4:OR_gate(3) with .In2 at Here;
    line right_ elen_/2 from X1.Out;corner;line down_ to (Here.x,X4.In1.y);corner;line to X4.In1
    line right_ elen_/2 from X3.Out;corner;line up_ to (Here.x,X4.In3.y);corner;line to X4.In3

    line right_ elen_/2 from X4.Out; "X" ljust;dot(,,1);

    .PE
    end{lstlisting}
    end{document}





    share|improve this answer






























      0














      enter image description here



      enter image description here



      documentclass[a4paper,11pt]{article}
      %documentclass[a4paper,11pt]{standalone}% for demontration only!
      usepackage[top=0.75in, bottom=0.75in, left=0.75in, right=0.75in]{geometry}
      %usepackage{showframe}% for demontration only!
      pagestyle{empty}
      usepackage{xcolor}
      usepackage{listings}

      definecolor{Others}{RGB}{0,110,40} % Green
      definecolor{Character}{RGB}{146,76,157} % Purple
      definecolor{Number}{RGB}{176,128,0} % Brown

      lstdefinestyle{circuit_macros}
      {
      basicstyle=scriptsizettfamilynull,
      literate=*{,}{{color{black}{,}}}1%
      0{{textcolor{Number}0}}1%
      1{{textcolor{Number}1}}1%
      2{{textcolor{Number}2}}1%
      3{{textcolor{Number}3}}1%
      4{{textcolor{Number}4}}1%
      5{{textcolor{Number}5}}1%
      6{{textcolor{Number}6}}1%
      7{{textcolor{Number}7}}1%
      8{{textcolor{Number}8}}1%
      9{{textcolor{Number}9}}1%
      ({{color{Character}{(}}}1%
      ){{color{Character}{)}}}1%
      /{{color{black}{/}}}1%
      :{{color{Character}{:}}}1%
      ;{{color{black}{;}}}1%
      .{{color{black}{.}}}1%
      ({{color{Character}{(}}}1%
      {.0}{{textcolor{Number}{.0}}}1%
      {.1}{{color{Number}{.1}}}1%
      {.2}{{color{Number}{.2}}}1%
      {.3}{{color{Number}{.3}}}1%
      {.4}{{color{Number}{.4}}}1%
      {.5}{{color{Number}{.5}}}1%
      {.6}{{color{Number}{.6}}}1%
      {.7}{{color{Number}{.7}}}1%
      {.8}{{color{Number}{.8}}}1%
      {.9}{{color{Number}{.9}}}1%
      %
      *{{color{black}{*}}}2%
      {O:}{{color{Character}{O:}}}2%
      {A.}{{color{black}{A.}}}2%
      {B.}{{color{black}{B.}}}2%
      {C.}{{color{black}{C.}}}2%
      {A:}{{color{Character}{A:}}}2%
      {B:}{{color{Character}{B:}}}2%
      {C:}{{color{Character}{C:}}}2%
      {DA:}{{color{Character}{DA:}}}3%
      {DB:}{{color{Character}{DB:}}}3%
      {DC:}{{color{Character}{DC:}}}3%
      {LA.}{{color{black}{LA.}}}3%
      {LB.}{{color{black}{LB.}}}3%
      {LC.}{{color{black}{LC.}}}3%
      {LA:}{{color{Character}{LA:}}}3%
      {LB:}{{color{Character}{LB:}}}3%
      {LC:}{{color{Character}{LC:}}}3%
      {X1}{{color{black}{X1}}}2%
      {X1:}{{color{Character}{X1:}}}3%
      {X2}{{color{black}{X2:}}}2%
      {X2:}{{color{Character}{X2:}}}3%
      {X3}{{color{black}{X3:}}}2%
      {X3:}{{color{Character}{X3:}}}3%
      {X4}{{color{black}{X4:}}}2%
      {X4:}{{color{Character}{X4:}}}3%
      {"A"}{{bfcolor{red}{"A"}}}3%
      {"B"}{{bfcolor{red}{"B"}}}3%
      {"C"}{{bfcolor{red}{"C"}}}3%
      {"X"}{{color{red}{"X"}}}3%
      {In1}{{color{black}{In1}}}3%
      {In2}{{color{black}{In2}}}3%
      {In3}{{color{black}{In3}}}3%
      {In4}{{color{black}{In4}}}3%
      ,
      emph={scale,above,with,at,Here,line,to,end,start,from,ljust},
      emphstyle={bfcolor{black}},
      morekeywords=[3]{PS,PE},
      keywordstyle=[3]{color{Character}},
      morekeywords=[5]{down_,up_,elen_,right_,log_init,NOT_gate,dot,AND_gate,OR_gate},
      keywordstyle=[5]color{Others},
      sensitive=false,
      morecomment=[l][color{gray}]{#},
      }

      begin{document}

      begin{lstlisting}[style=circuit_macros]
      % `logic.cir'

      .PS

      scale=25.4
      log_init

      #setrgb(0,0,1) # Blue Color
      #dot(,,1)

      O:(0,0)

      "A" at Here above;DA:dot(,,1);
      line down_ elen_/2 with .start at DA.s;dot;{A:line down_ 3.5*elen_};line right_ elen_/2;corner;
      line down_ elen_/2;NOT_gate;LA:line down_ to (Here.x,A.end.y);

      "B" at (elen_,0) above;DB:dot(,,1);
      line down_ elen_/2 with .start at DB.s;dot;{B:line down_ 3.5*elen_};line right_ elen_/2;corner;
      line down_ elen_/2;NOT_gate;LB:line to (Here.x,B.end.y);

      "C" at (2*elen_,0) above;DC:dot(,,1);
      line down_ elen_/2 with .start at DC.s;dot;{C:line down_ 3.5*elen_};line right_ elen_/2;corner;
      line down_ elen_/2;NOT_gate;LC:line to (Here.x,C.end.y);

      right_

      X1:AND_gate(2) at (3*elen_,LC.y+15)
      line from X1.In1 to (LA.x,X1.In1.y);dot
      line from X1.In2 to (LB.x,X1.In2.y);dot

      X2:AND_gate(2) at (X1.x,X1.y-15);
      line from X2.In1 to (LB.x,X2.In1.y);dot
      line from X2.In2 to (C.x,X2.In2.y);dot

      X3:AND_gate(3) at (X1.x,X1.y-30);
      line from X3.In1 to (A.x,X3.In1.y);dot
      line from X3.In2 to (B.x,X3.In2.y);dot
      line from X3.In3 to (LC.x,X3.In3.y);dot

      line right_ elen_ from X2.Out;X4:OR_gate(3) with .In2 at Here;
      line right_ elen_/2 from X1.Out;corner;line down_ to (Here.x,X4.In1.y);corner;line to X4.In1
      line right_ elen_/2 from X3.Out;corner;line up_ to (Here.x,X4.In3.y);corner;line to X4.In3

      line right_ elen_/2 from X4.Out; "X" ljust;dot(,,1);

      .PE
      end{lstlisting}
      end{document}





      share|improve this answer




























        0












        0








        0







        enter image description here



        enter image description here



        documentclass[a4paper,11pt]{article}
        %documentclass[a4paper,11pt]{standalone}% for demontration only!
        usepackage[top=0.75in, bottom=0.75in, left=0.75in, right=0.75in]{geometry}
        %usepackage{showframe}% for demontration only!
        pagestyle{empty}
        usepackage{xcolor}
        usepackage{listings}

        definecolor{Others}{RGB}{0,110,40} % Green
        definecolor{Character}{RGB}{146,76,157} % Purple
        definecolor{Number}{RGB}{176,128,0} % Brown

        lstdefinestyle{circuit_macros}
        {
        basicstyle=scriptsizettfamilynull,
        literate=*{,}{{color{black}{,}}}1%
        0{{textcolor{Number}0}}1%
        1{{textcolor{Number}1}}1%
        2{{textcolor{Number}2}}1%
        3{{textcolor{Number}3}}1%
        4{{textcolor{Number}4}}1%
        5{{textcolor{Number}5}}1%
        6{{textcolor{Number}6}}1%
        7{{textcolor{Number}7}}1%
        8{{textcolor{Number}8}}1%
        9{{textcolor{Number}9}}1%
        ({{color{Character}{(}}}1%
        ){{color{Character}{)}}}1%
        /{{color{black}{/}}}1%
        :{{color{Character}{:}}}1%
        ;{{color{black}{;}}}1%
        .{{color{black}{.}}}1%
        ({{color{Character}{(}}}1%
        {.0}{{textcolor{Number}{.0}}}1%
        {.1}{{color{Number}{.1}}}1%
        {.2}{{color{Number}{.2}}}1%
        {.3}{{color{Number}{.3}}}1%
        {.4}{{color{Number}{.4}}}1%
        {.5}{{color{Number}{.5}}}1%
        {.6}{{color{Number}{.6}}}1%
        {.7}{{color{Number}{.7}}}1%
        {.8}{{color{Number}{.8}}}1%
        {.9}{{color{Number}{.9}}}1%
        %
        *{{color{black}{*}}}2%
        {O:}{{color{Character}{O:}}}2%
        {A.}{{color{black}{A.}}}2%
        {B.}{{color{black}{B.}}}2%
        {C.}{{color{black}{C.}}}2%
        {A:}{{color{Character}{A:}}}2%
        {B:}{{color{Character}{B:}}}2%
        {C:}{{color{Character}{C:}}}2%
        {DA:}{{color{Character}{DA:}}}3%
        {DB:}{{color{Character}{DB:}}}3%
        {DC:}{{color{Character}{DC:}}}3%
        {LA.}{{color{black}{LA.}}}3%
        {LB.}{{color{black}{LB.}}}3%
        {LC.}{{color{black}{LC.}}}3%
        {LA:}{{color{Character}{LA:}}}3%
        {LB:}{{color{Character}{LB:}}}3%
        {LC:}{{color{Character}{LC:}}}3%
        {X1}{{color{black}{X1}}}2%
        {X1:}{{color{Character}{X1:}}}3%
        {X2}{{color{black}{X2:}}}2%
        {X2:}{{color{Character}{X2:}}}3%
        {X3}{{color{black}{X3:}}}2%
        {X3:}{{color{Character}{X3:}}}3%
        {X4}{{color{black}{X4:}}}2%
        {X4:}{{color{Character}{X4:}}}3%
        {"A"}{{bfcolor{red}{"A"}}}3%
        {"B"}{{bfcolor{red}{"B"}}}3%
        {"C"}{{bfcolor{red}{"C"}}}3%
        {"X"}{{color{red}{"X"}}}3%
        {In1}{{color{black}{In1}}}3%
        {In2}{{color{black}{In2}}}3%
        {In3}{{color{black}{In3}}}3%
        {In4}{{color{black}{In4}}}3%
        ,
        emph={scale,above,with,at,Here,line,to,end,start,from,ljust},
        emphstyle={bfcolor{black}},
        morekeywords=[3]{PS,PE},
        keywordstyle=[3]{color{Character}},
        morekeywords=[5]{down_,up_,elen_,right_,log_init,NOT_gate,dot,AND_gate,OR_gate},
        keywordstyle=[5]color{Others},
        sensitive=false,
        morecomment=[l][color{gray}]{#},
        }

        begin{document}

        begin{lstlisting}[style=circuit_macros]
        % `logic.cir'

        .PS

        scale=25.4
        log_init

        #setrgb(0,0,1) # Blue Color
        #dot(,,1)

        O:(0,0)

        "A" at Here above;DA:dot(,,1);
        line down_ elen_/2 with .start at DA.s;dot;{A:line down_ 3.5*elen_};line right_ elen_/2;corner;
        line down_ elen_/2;NOT_gate;LA:line down_ to (Here.x,A.end.y);

        "B" at (elen_,0) above;DB:dot(,,1);
        line down_ elen_/2 with .start at DB.s;dot;{B:line down_ 3.5*elen_};line right_ elen_/2;corner;
        line down_ elen_/2;NOT_gate;LB:line to (Here.x,B.end.y);

        "C" at (2*elen_,0) above;DC:dot(,,1);
        line down_ elen_/2 with .start at DC.s;dot;{C:line down_ 3.5*elen_};line right_ elen_/2;corner;
        line down_ elen_/2;NOT_gate;LC:line to (Here.x,C.end.y);

        right_

        X1:AND_gate(2) at (3*elen_,LC.y+15)
        line from X1.In1 to (LA.x,X1.In1.y);dot
        line from X1.In2 to (LB.x,X1.In2.y);dot

        X2:AND_gate(2) at (X1.x,X1.y-15);
        line from X2.In1 to (LB.x,X2.In1.y);dot
        line from X2.In2 to (C.x,X2.In2.y);dot

        X3:AND_gate(3) at (X1.x,X1.y-30);
        line from X3.In1 to (A.x,X3.In1.y);dot
        line from X3.In2 to (B.x,X3.In2.y);dot
        line from X3.In3 to (LC.x,X3.In3.y);dot

        line right_ elen_ from X2.Out;X4:OR_gate(3) with .In2 at Here;
        line right_ elen_/2 from X1.Out;corner;line down_ to (Here.x,X4.In1.y);corner;line to X4.In1
        line right_ elen_/2 from X3.Out;corner;line up_ to (Here.x,X4.In3.y);corner;line to X4.In3

        line right_ elen_/2 from X4.Out; "X" ljust;dot(,,1);

        .PE
        end{lstlisting}
        end{document}





        share|improve this answer















        enter image description here



        enter image description here



        documentclass[a4paper,11pt]{article}
        %documentclass[a4paper,11pt]{standalone}% for demontration only!
        usepackage[top=0.75in, bottom=0.75in, left=0.75in, right=0.75in]{geometry}
        %usepackage{showframe}% for demontration only!
        pagestyle{empty}
        usepackage{xcolor}
        usepackage{listings}

        definecolor{Others}{RGB}{0,110,40} % Green
        definecolor{Character}{RGB}{146,76,157} % Purple
        definecolor{Number}{RGB}{176,128,0} % Brown

        lstdefinestyle{circuit_macros}
        {
        basicstyle=scriptsizettfamilynull,
        literate=*{,}{{color{black}{,}}}1%
        0{{textcolor{Number}0}}1%
        1{{textcolor{Number}1}}1%
        2{{textcolor{Number}2}}1%
        3{{textcolor{Number}3}}1%
        4{{textcolor{Number}4}}1%
        5{{textcolor{Number}5}}1%
        6{{textcolor{Number}6}}1%
        7{{textcolor{Number}7}}1%
        8{{textcolor{Number}8}}1%
        9{{textcolor{Number}9}}1%
        ({{color{Character}{(}}}1%
        ){{color{Character}{)}}}1%
        /{{color{black}{/}}}1%
        :{{color{Character}{:}}}1%
        ;{{color{black}{;}}}1%
        .{{color{black}{.}}}1%
        ({{color{Character}{(}}}1%
        {.0}{{textcolor{Number}{.0}}}1%
        {.1}{{color{Number}{.1}}}1%
        {.2}{{color{Number}{.2}}}1%
        {.3}{{color{Number}{.3}}}1%
        {.4}{{color{Number}{.4}}}1%
        {.5}{{color{Number}{.5}}}1%
        {.6}{{color{Number}{.6}}}1%
        {.7}{{color{Number}{.7}}}1%
        {.8}{{color{Number}{.8}}}1%
        {.9}{{color{Number}{.9}}}1%
        %
        *{{color{black}{*}}}2%
        {O:}{{color{Character}{O:}}}2%
        {A.}{{color{black}{A.}}}2%
        {B.}{{color{black}{B.}}}2%
        {C.}{{color{black}{C.}}}2%
        {A:}{{color{Character}{A:}}}2%
        {B:}{{color{Character}{B:}}}2%
        {C:}{{color{Character}{C:}}}2%
        {DA:}{{color{Character}{DA:}}}3%
        {DB:}{{color{Character}{DB:}}}3%
        {DC:}{{color{Character}{DC:}}}3%
        {LA.}{{color{black}{LA.}}}3%
        {LB.}{{color{black}{LB.}}}3%
        {LC.}{{color{black}{LC.}}}3%
        {LA:}{{color{Character}{LA:}}}3%
        {LB:}{{color{Character}{LB:}}}3%
        {LC:}{{color{Character}{LC:}}}3%
        {X1}{{color{black}{X1}}}2%
        {X1:}{{color{Character}{X1:}}}3%
        {X2}{{color{black}{X2:}}}2%
        {X2:}{{color{Character}{X2:}}}3%
        {X3}{{color{black}{X3:}}}2%
        {X3:}{{color{Character}{X3:}}}3%
        {X4}{{color{black}{X4:}}}2%
        {X4:}{{color{Character}{X4:}}}3%
        {"A"}{{bfcolor{red}{"A"}}}3%
        {"B"}{{bfcolor{red}{"B"}}}3%
        {"C"}{{bfcolor{red}{"C"}}}3%
        {"X"}{{color{red}{"X"}}}3%
        {In1}{{color{black}{In1}}}3%
        {In2}{{color{black}{In2}}}3%
        {In3}{{color{black}{In3}}}3%
        {In4}{{color{black}{In4}}}3%
        ,
        emph={scale,above,with,at,Here,line,to,end,start,from,ljust},
        emphstyle={bfcolor{black}},
        morekeywords=[3]{PS,PE},
        keywordstyle=[3]{color{Character}},
        morekeywords=[5]{down_,up_,elen_,right_,log_init,NOT_gate,dot,AND_gate,OR_gate},
        keywordstyle=[5]color{Others},
        sensitive=false,
        morecomment=[l][color{gray}]{#},
        }

        begin{document}

        begin{lstlisting}[style=circuit_macros]
        % `logic.cir'

        .PS

        scale=25.4
        log_init

        #setrgb(0,0,1) # Blue Color
        #dot(,,1)

        O:(0,0)

        "A" at Here above;DA:dot(,,1);
        line down_ elen_/2 with .start at DA.s;dot;{A:line down_ 3.5*elen_};line right_ elen_/2;corner;
        line down_ elen_/2;NOT_gate;LA:line down_ to (Here.x,A.end.y);

        "B" at (elen_,0) above;DB:dot(,,1);
        line down_ elen_/2 with .start at DB.s;dot;{B:line down_ 3.5*elen_};line right_ elen_/2;corner;
        line down_ elen_/2;NOT_gate;LB:line to (Here.x,B.end.y);

        "C" at (2*elen_,0) above;DC:dot(,,1);
        line down_ elen_/2 with .start at DC.s;dot;{C:line down_ 3.5*elen_};line right_ elen_/2;corner;
        line down_ elen_/2;NOT_gate;LC:line to (Here.x,C.end.y);

        right_

        X1:AND_gate(2) at (3*elen_,LC.y+15)
        line from X1.In1 to (LA.x,X1.In1.y);dot
        line from X1.In2 to (LB.x,X1.In2.y);dot

        X2:AND_gate(2) at (X1.x,X1.y-15);
        line from X2.In1 to (LB.x,X2.In1.y);dot
        line from X2.In2 to (C.x,X2.In2.y);dot

        X3:AND_gate(3) at (X1.x,X1.y-30);
        line from X3.In1 to (A.x,X3.In1.y);dot
        line from X3.In2 to (B.x,X3.In2.y);dot
        line from X3.In3 to (LC.x,X3.In3.y);dot

        line right_ elen_ from X2.Out;X4:OR_gate(3) with .In2 at Here;
        line right_ elen_/2 from X1.Out;corner;line down_ to (Here.x,X4.In1.y);corner;line to X4.In1
        line right_ elen_/2 from X3.Out;corner;line up_ to (Here.x,X4.In3.y);corner;line to X4.In3

        line right_ elen_/2 from X4.Out; "X" ljust;dot(,,1);

        .PE
        end{lstlisting}
        end{document}






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 2 at 5:39

























        answered Mar 2 at 5:34









        KJOKJO

        3,6701222




        3,6701222






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475923%2fhow-do-i-customize-circuit-macros-in-listings%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            El tren de la libertad Índice Antecedentes "Porque yo decido" Desarrollo de la...

            Castillo d'Acher Características Menú de navegación

            Connecting two nodes from the same mother node horizontallyTikZ: What EXACTLY does the the |- notation for...