I want to put some LaTeX source code in my PDF output with the style like this:

Color in text mode is white, in math mode is yellow and in comments is grey. For control sequences, I divide it into four kinds with different highlight mode:
- Commands in text mode are cyan, and its argument(s) (non-optional) is/are orange and italic.
- Commands in text mode are cyan, but its argument(s) (non-optional) is/are white and upright.
- Commands in text mode are rose-color, and its optional argument(s) is/are orange and italic, non-optional argument(s) is/are cyan and italic.
- Commands in math mode are purple, its arguments (optional or non-optional) should be rose-color and upright.
Remember that backslash before a command is always highlighted with the same color of the command, but delimiters of arguments remains white (color of body text).
I tried and searched the web for about ten hours, but still failed. Any hints or clues would be appreciated.

mintedis probably you best bet. – You Dec 01 '13 at 12:08minted, however, I couldn't compile a simple example provided by it. What's worse, I'm not familiar with Python, so.. Should I open another question for those problems? – Tachibana Kanade Dec 06 '13 at 03:22minted, or other script-based packages (am I right?). The reason, I guess, is that these script languages provide much more controlling and conditional switching than LaTeX itself does. I will follow your advice to study these packages when I get rid of my current article. :) – Tachibana Kanade Dec 06 '13 at 03:34{}), optional ones in square brackets ([]) and start a control sequence with a backslash (\), situation goes much knottier. – Tachibana Kanade Dec 06 '13 at 03:43listingscan do a lot, but nothing can be done without precise highlighting specifications. – jub0bs Mar 18 '14 at 16:08monokaitheme will give you the desired output. – fractal Mar 16 '20 at 13:41