如何在 LaTeX 中漂亮地显示 Git 控制台日志(==彩色文本)?

如何在 LaTeX 中漂亮地显示 Git 控制台日志(==彩色文本)?

我基本上想要一个直接的 LaTeX 格式的类似输出,如下图所示。背景颜色并不重要,但例如提交哈希、提交消息和分支的不同颜色很重要。

==> 我必须承认,我还没有尝试过“手动”方法 - 所以我基本上是在寻找如何获得最佳结果的技巧。

==> 目前,我只使用像下面这样的图片 - 但与仅使用文本相比,处理它们感觉效果不佳。

编辑此外:虽然我还没有尝试过文本输出,但我认为左侧的星星和线条(确实显示分支结构)会产生很多问题,因为我不能使用任何多列的东西。对吗?

谢谢

第二次编辑:我刚刚找到这个答案:如何在 LaTeX 中生成 Git 存储库的历史图表?这并不能完全回答我的问题,但有一点帮助 - 至少我完全忽略了它。==> 对不起。

git log --oneline --graph --all --decorate=short

答案1

如果你

git log --color --graph --oneline > l.txt

然后您将获得包括 l.txt 中的终端颜色代码在内的历史记录,然后您可以将其复制到逐字环境中。

在这里,我只是^^[激活并抓取所有内容,然后m键入所用终端代码的警告,因此您只需在每种情况下定义一个合适的定义即可。您可以查找代码,我编写了一些代码,而不是检查确切的颜色。

在此处输入图片描述

\documentclass{article}
\usepackage{color}
\begin{document}

{
\let\XXegroup\relax
\expandafter\def\csname XX[31\endcsname{%
  \bgroup\let\XXegroup\egroup\leavevmode\color{red}}
\expandafter\def\csname XX[1;31\endcsname{%
  \bgroup\let\XXegroup\egroup\leavevmode\bfseries\color{red}}
\expandafter\def\csname XX[32\endcsname{%
  \bgroup\let\XXegroup\egroup\leavevmode\color{green}}
\expandafter\def\csname XX[1;32\endcsname{%
  \bgroup\let\XXegroup\egroup\leavevmode\bfseries\color{green}}
\expandafter\def\csname XX[33\endcsname{%
  \bgroup\let\XXegroup\egroup\leavevmode\color{yellow}}
\expandafter\def\csname XX[1;33\endcsname{%
  \bgroup\let\XXegroup\egroup\leavevmode\bfseries\color{yellow}}
\expandafter\def\csname XX[34\endcsname{%
  \bgroup\let\XXegroup\egroup\leavevmode\color{cyan}}
\expandafter\def\csname XX[1;34\endcsname{%
  \bgroup\let\XXegroup\egroup\leavevmode\bfseries\color{cyan}}
\expandafter\def\csname XX[35\endcsname{%
  \bgroup\let\XXegroup\egroup\leavevmode\color{magenta}}
\expandafter\def\csname XX[1;35\endcsname{%
  \bgroup\let\XXegroup\egroup\leavevmode\bfseries\color{magenta}}
\expandafter\def\csname XX[36\endcsname{%
  \bgroup\let\XXegroup\egroup\leavevmode\color{blue}}
\expandafter\def\csname XX[1;36\endcsname{%
  \bgroup\let\XXegroup\egroup\leavevmode\bfseries\color{blue}}


\expandafter\def\csname XX[\endcsname{\XXegroup}
\catcode`\^^[=13
\def^^[#1m{%
\expandafter\ifx\csname XX#1\endcsname\relax
\typeout{XX#1}%
\else
\csname XX#1\endcsname
\fi}
\
\begin{verbatim}
* [33m5f31460[m modify newtoken usage
* [33m07278ee[m updates for luatex 0.87
*   [33m0f6cd3d[m Merge pull request #59 from dohyunkim/master
[32m|[m[33m\[m  
[32m|[m * [33m05359e2[m adapt to luatex 2015/10/01; v2.11.1
[32m|[m * [33m8b907ae[m v2.11.1
[32m|[m * [33m2be8e99[m merge master
[32m|[m * [33m5de368e[m minor
[32m|[m * [33me145179[m revert parsing routine to 9d4c96b
[32m|[m * [33m9ebfce3[m minor
[32m|[m * [33macde0ca[m fix a bug of prev commit
[32m|[m * [33m0c69d64[m allow btex ... etex even under mplibverbatim
[32m|[m * [33m9d4c96b[m no mplibpreamble upon verbatim mode
* [33m|[m   [33m1aadbba[m Merge pull request #58 from dohyunkim/master
[34m|[m[33m\[m [33m\[m  
[34m|[m [33m|[m[33m/[m  
[34m|[m * [33mfb5ac2a[m \mplibverbatim{enable}. v2.11.0
[34m|[m * [33m7289e85[m use newtoken for checking pgf package
[34m|[m * [33m8f3e229[m simpler approach to compatible-with-beamer issue
[34m|[m * [33mb5b18c1[m allow access to type1 fonts
[34m|[m * [33m93ff22d[m check the existence of pgf token list using allocation number
[34m|[m * [33m1915aa7[m tex.tprint for the argument of pdfliteral
[34m|[m * [33m2696417[m check luaotfload package
[34m|[m * [33m2200616[m respect pgf transparency
[34m|[m[34m/[m  
*   [33mdf701d3[m Merge pull request #57 from dohyunkim/master
[36m|[m[1;31m\[m  
[36m|[m * [33m5eae346[m address #55 again
* [1;31m|[m   [33m9c13a7a[m Merge pull request #56 from dohyunkim/master
[1;32m|[m[1;31m\[m [1;31m\[m  
[1;32m|[m [1;31m|[m[1;31m/[m  
[1;32m|[m * [33m1b418b7[m fix bug #55 regarding hash token
* [1;33m|[m   [33m8c3b5a0[m Merge pull request #54 from dohyunkim/master
[1;34m|[m[1;33m\[m [1;33m\[m  
[1;34m|[m [1;33m|[m[1;33m/[m  
[1;34m|[m * [33mec9504b[m ver 2.10.0
[1;34m|[m * [33mf2fe56e[m minor
[1;34m|[m * [33mbde5bc5[m \mpcolor now accepts optional argument
[1;34m|[m * [33m5670830[m minor
[1;34m|[m * [33mfca7581[m bug: divide by 0
[1;34m|[m * [33m11a6ab4[m do not ignore VerbatimTeX() between beginfig and endfig
[1;34m|[m * [33m7d77d39[m minor: reduce duplicates
* [1;35m|[m   [33m96f2718[m Merge pull request #53 from dohyunkim/master
[1;36m|[m[1;35m\[m [1;35m\[m  
[1;36m|[m [1;35m|[m[1;35m/[m  
[1;36m|[m * [33m8417f30[m fix a bug reported via luatex mailing
* [31m|[m   [33m82006b9[m Merge pull request #51 from dohyunkim/master
[32m|[m[31m\[m [31m\[m  
[32m|[m [31m|[m[31m/[m  
[32m|[m * [33mc90f93d[m add some note about mplibcodeinherit
* [33m|[m   [33ma0714f5[m Merge pull request #50 from dohyunkim/master
[34m|[m[33m\[m [33m\[m  
[34m|[m [33m|[m[33m/[m  
[34m|[m * [33mb455d84[m introduce \mplibcodeinherit
* [35m|[m   [33md29da12[m Merge pull request #48 from dohyunkim/master
[36m|[m[35m\[m [35m\[m  
[36m|[m [35m|[m[35m/[m  
[36m|[m * [33mf038aeb[m fix failure at btex \% etex
[36m|[m * [33me9d3abd[m color package on plain tex: test file
[36m|[m * [33mbbb2c11[m color package on plain tex
* [1;31m|[m   [33ma0a071c[m Merge pull request #47 from dohyunkim/master
[1;32m|[m[1;31m\[m [1;31m\[m  
[1;32m|[m [1;31m|[m[1;31m/[m  
[1;32m|[m * [33mc14cd6a[m withoutcolor in dvi mode
[1;32m|[m * [33madeac15[m dvipdfmx color special
[1;32m|[m * [33m3a4b9fd[m suport spotcolor as well
[1;32m|[m * [33m2599413[m remove redundancy; update news
[1;32m|[m * [33me3e3eac[m \mpxcolor for xcolor support
[1;32m|[m * [33m33dac8c[m add mp-luas.mpiv to noneedtoreplace table
[1;32m|[m * [33mf5a6fb7[m default TEXMFDIR is now TEXMFHOME
* [1;33m|[m   [33m751db55[m Merge pull request #46 from dohyunkim/master
[1;34m|[m[1;33m\[m [1;33m\[m  
[1;34m|[m [1;33m|[m[1;33m/[m  
[1;34m|[m * [33maf0c6e0[m TEXMFVAR might not exist
[1;34m|[m * [33mfc3cdf8[m new default cache dir
[1;34m|[m * [33m843983b[m support luatexbase 0.7- as well
[1;34m|[m * [33mb80db8d[m reused box can have mplibcode
[1;34m|[m * [33ma13a14a[m support dvipdfmx
[1;34m|[m * [33m574cc79[m indent uniformity
[1;34m|[m * [33m735dc9f[m adapt to new luatex engine and future luatexbase
[1;34m|[m * [33m95c39c2[m fix luatex crash under decimal mode
* [1;35m|[m   [33m515b95c[m Merge pull request #44 from dohyunkim/master
[1;36m|[m[1;35m\[m [1;35m\[m  
[1;36m|[m [1;35m|[m[1;35m/[m  
[1;36m|[m * [33m161ac34[m respect show command
[1;36m|[m * [33mfdc08d7[m minor
[1;36m|[m * [33mc965f75[m delete redundancy
[1;36m|[m * [33m6334db8[m fix bug regarding color and %g
* [31m|[m   [33mdd0fefc[m Merge pull request #42 from dohyunkim/master
[32m|[m[31m\[m [31m\[m  
[32m|[m [31m|[m[31m/[m  
[32m|[m * [33md53dc9d[m random_seed is int type
[32m|[m * [33mbd73b20[m add randomseed to load()
[32m|[m * [33m864f690[m follow mp code convention
[32m|[m * [33mcb51d91[m fontsize too ignore font part
* [33m|[m   [33ma294373[m Merge pull request #41 from dohyunkim/master
[34m|[m[33m\[m [33m\[m  
[34m|[m [33m|[m[33m/[m  
[34m|[m * [33m349cb9e[m warn textext() anomaly
[34m|[m * [33m4fa622c[m ignore font part of infont; avoid outputbox
[34m|[m * [33mc0578d7[m mention \MPllx etc
* [35m|[m   [33m6844fb5[m Merge pull request #40 from dohyunkim/master
[36m|[m[35m\[m [35m\[m  
[36m|[m [35m|[m[35m/[m  
[36m|[m * [33mebf594a[m detokenize rather than unexpanded for textext protection
* [1;31m|[m   [33m546dd44[m Merge pull request #38 from dohyunkim/master
[1;32m|[m[1;31m\[m [1;31m\[m  
[1;32m|[m [1;31m|[m[1;31m/[m  
[1;32m|[m * [33m2ade1c1[m redefine fontsize as well
* [1;33m|[m   [33mbbfb821[m Merge pull request #37 from dohyunkim/master
[1;34m|[m[1;33m\[m [1;33m\[m  
[1;34m|[m [1;33m|[m[1;33m/[m  
[1;34m|[m * [33mfd47c4a[m minor doc update
[1;34m|[m * [33me680e55[m simpler infont
* [1;35m|[m   [33m976e452[m Merge pull request #36 from dohyunkim/master
[1;36m|[m[1;35m\[m [1;35m\[m  
[1;36m|[m [1;35m|[m[1;35m/[m  
[1;36m|[m * [33m94a9a7c[m redefine infont instead of thelabel
[1;36m|[m * [33m5fcc187[m \mplibtextextlabel{enable}
* [31m|[m   [33m7990d6b[m Merge pull request #34 from dohyunkim/master
[32m|[m[31m\[m [31m\[m  
[32m|[m [31m|[m[31m/[m  
[32m|[m * [33mca8fca2[m use lfs.touch to identify original input file
[32m|[m * [33ma661f8b[m respect -output-directory
[32m|[m * [33m6759215[m --safer prevents caching
[32m|[m * [33m8d83566[m minor
[32m|[m * [33m48997b9[m 2.5.3
[32m|[m * [33m285fc6b[m cachedir under
* [33m|[m   [33m9898207[m Merge pull request #33 from dohyunkim/master
[34m|[m[33m\[m [33m\[m  
[34m|[m [33m|[m[33m/[m  
[34m|[m * [33mca2d466[m v2.5.2
* [35m|[m   [33mcdb8bd8[m Merge pull request #32 from dohyunkim/master
[36m|[m[35m\[m [35m\[m  
[36m|[m [35m|[m[35m/[m  
[36m|[m * [33m804de35[m [fix] newline char after \endmplibcode
* [1;31m|[m   [33m06efef0[m Merge pull request #31 from dohyunkim/master
[1;32m|[m[1;31m\[m [1;31m\[m  
[1;32m|[m [1;31m|[m[1;31m/[m  
[1;32m|[m * [33m97025d1[m [fix] \everymplib{%^^M
* [1;33m|[m   [33m33a1f69[m Merge pull request #29 from dohyunkim/master
[1;34m|[m[1;33m\[m [1;33m\[m  
[1;34m|[m [1;33m|[m[1;33m/[m  
[1;34m|[m * [33mcc56dff[m minor typo in doc
[1;34m|[m * [33me393870[m cache should be newer than luamplib.lua as well
[1;34m|[m * [33m89aedee[m \mplibmakenocache, \mplibcancelnocache
* [1;35m|[m   [33mbaa825c[m Merge pull request #28 from dohyunkim/master
[1;36m|[m[1;35m\[m [1;35m\[m  
[1;36m|[m [1;35m|[m[1;35m/[m  
[1;36m|[m * [33mb87847d[m date
[1;36m|[m * [33ma6f1bb7[m replace lf with cr after mplibcode
* [31m|[m   [33m65ffb67[m Merge pull request #27 from dohyunkim/master
[32m|[m[31m\[m [31m\[m  
[32m|[m [31m|[m[31m/[m  
[32m|[m * [33m0e8204d[m revert to \endlinechar
* [33m|[m   [33m66cb229[m Merge pull request #26 from dohyunkim/master
[34m|[m[33m\[m [33m\[m  
[34m|[m [33m|[m[33m/[m  
[34m|[m * [33m5291b7e[m use \obeylines instead of \endlinechar
[34m|[m * [33ma81fbcd[m tried graph.mp and fixed some bugs
* [35m|[m   [33m610ff68[m Merge pull request #25 from dohyunkim/master
[36m|[m[35m\[m [35m\[m  
[36m|[m [35m|[m[35m/[m  
[36m|[m * [33m34e68bd[m version minor upgrade
[36m|[m * [33m5e6c3d4[m reduce waste of resources
* [1;31m|[m   [33m274b124[m Merge pull request #24 from dohyunkim/master
[1;32m|[m[1;31m\[m [1;31m\[m  
[1;32m|[m [1;31m|[m[1;31m/[m  
[1;32m|[m * [33m78b1ec6[m update doc
[1;32m|[m * [33ma266f23[m we can replace input mp file in finder
[1;32m|[m * [33m7a57a4f[m input foo might be behind comment sign
[1;32m|[m * [33m7a2dcf7[m add notice on leavevmode; hack to allow input file in current dir
[1;32m|[m * [33mf50fab0[m finder can now find '.mf' file
[1;32m|[m * [33mcb1744d[m quasi-graphictext
* [1;33m|[m   [33m7300631[m Merge pull request #23 from dohyunkim/master
[1;34m|[m[1;33m\[m [1;33m\[m  
[1;34m|[m [1;33m|[m[1;33m/[m  
[1;34m|[m * [33m58f2f4d[m update doc
[1;34m|[m * [33m569d5a3[m TEXMFROOT -> TEXMFDIR in Makefile
[1;34m|[m * [33m880421c[m v2.4
* [1;35m|[m   [33ma091ffe[m Merge pull request #22 from dohyunkim/master
[1;36m|[m[1;35m\[m [1;35m\[m  
[1;36m|[m [1;35m|[m[1;35m/[m  
[1;36m|[m * [33m3145db1[m provides numbersystem option
* [31m|[m   [33m8d5d279[m Merge pull request #20 from dohyunkim/master
[32m|[m[31m\[m [31m\[m  
[32m|[m [31m|[m[31m/[m  
[32m|[m * [33m3a66817[m typo in doc
* [33m|[m   [33m0e66721[m Merge pull request #18 from dohyunkim/master
[34m|[m[33m\[m [33m\[m  
[34m|[m [33m|[m[33m/[m  
[34m|[m * [33mcad5ad7[m correct version
[34m|[m * [33m09806d0[m restore # which is doubled when expanded
* [35m|[m   [33mc82d9ea[m Merge pull request #17 from dohyunkim/master
[36m|[m[35m\[m [35m\[m  
[36m|[m [35m|[m[35m/[m  
[36m|[m * [33m5e5945d[m update doc
[36m|[m * [33mae6312a[m fix a bug in protexttextext()
* [1;31m|[m   [33mf06ddfb[m Merge pull request #16 from dohyunkim/master
[1;32m|[m[1;31m\[m [1;31m\[m  
[1;32m|[m [1;31m|[m[1;31m/[m  
[1;32m|[m * [33mf8e6afc[m minor
[1;32m|[m * [33m7ef55a1[m update news; minor fix
[1;32m|[m * [33m8fd1b45[m allow raw tex commands esp. \mpdim
[1;32m|[m * [33me02c7bb[m everymplib / everyendmplib
* [1;33m|[m   [33m796ff04[m Merge pull request #14 from dohyunkim/master
[1;34m|[m[1;33m\[m [1;33m\[m  
[1;34m|[m [1;33m|[m[1;33m/[m  
[1;34m|[m * [33maf45002[m fix bug of prescript parsing
[1;34m|[m * [33m1fea3ce[m repect only one verbatimtex before beginfig
* [1;35m|[m   [33m55b8656[m Merge pull request #13 from dohyunkim/master
[1;36m|[m[1;35m\[m [1;35m\[m  
[1;36m|[m [1;35m|[m[1;35m/[m  
[1;36m|[m * [33m0e61997[m update news
[1;36m|[m * [33m7f2b407[m do not ignore verbatimtex ... etex before beginfig()
[1;36m|[m * [33mde9c70d[m a little smaller pdf file
[1;36m|[m * [33macce6ae[m btex ... etex should be converted to rawtextext
[1;36m|[m * [33mfd1f451[m minor
[1;36m|[m * [33m3b4c198[m reverse order of transparency and shading
[1;36m|[m * [33mb4ed015[m %.3g instead of %.3f
[1;36m|[m * [33m3bc6a65[m metafun's transparency and shading
* [31m|[m   [33mf825ac0[m Merge pull request #11 from dohyunkim/master
[32m|[m[31m\[m [31m\[m  
[32m|[m [31m|[m[31m/[m  
[32m|[m * [33m6c4309a[m repect suffix of textext in metafun
[32m|[m * [33m67fe8af[m ignore fontmapfile primitive
[32m|[m * [33m188cebc[m rudimentary support of metafun format
[32m|[m * [33mf953ce9[m fix a bug regarding char <num> infont <font>
[32m|[m * [33md564c02[m fix a bug wrt withoutcolor option
* [33m|[m   [33m0c19957[m Merge pull request #10 from dohyunkim/master
[34m|[m[33m\[m [33m\[m  
[34m|[m [33m|[m[33m/[m  
[34m|[m * [33m2047fe9[m avoid error wrt 'withoutcolor'
* [35m|[m   [33m2a91178[m Merge pull request #9 from dohyunkim/master
[36m|[m[35m\[m [35m\[m  
[36m|[m [35m|[m[35m/[m  
[36m|[m * [33m17a6414[m recognize withcolor option for normal text as well
[36m|[m * [33m61810e4[m do not ignore 'withcolor' option
[36m|[m * [33m65f9ebd[m add some more test figs
[36m|[m * [33mb87ca4b[m mpfun seems to be a typo
[36m|[m * [33m5d85ab4[m making doc needs lualatex not pdflatex
[36m|[m * [33md564223[m more robust btex ... etex parsing
[36m|[m * [33mecbb950[m begingroup/endgroup is better than bgroup/egroup
[36m|[m * [33m6fabc67[m plain tex's mplibcode too is now local
* [1;31m|[m   [33mbc9f420[m Merge pull request #8 from dohyunkim/master
[1;32m|[m[1;31m\[m [1;31m\[m  
[1;32m|[m [1;31m|[m[1;31m/[m  
[1;32m|[m * [33m7dc700c[m v2.03
[1;32m|[m * [33m9a25014[m impl. textext(), TEX()
[1;32m|[m * [33m97ddbce[m minor change to latexmk options
[1;32m|[m * [33m11525df[m fix a bug regarding tex-text box inside for loop
[1;32m|[m * [33m33f7013[m ctan requires luamplib subdir
* [1;33m|[m   [33me5f985c[m Merge pull request #7 from dohyunkim/master
[1;34m|[m[1;33m\[m [1;33m\[m  
[1;34m|[m [1;33m|[m[1;33m/[m  
[1;34m|[m * [33mb61f744[m v2.01
* [1;35m|[m   [33m093d63a[m Merge pull request #6 from dohyunkim/master
[1;36m|[m[1;35m\[m [1;35m\[m  
[1;36m|[m [1;35m|[m[1;35m/[m  
[1;36m|[m * [33m5a84aae[m more fix about wrong baseline
[1;36m|[m * [33meea378c[m revert previous four commits
[1;36m|[m * [33mf791161[m allow mplibcode option [nopreamble]
[1;36m|[m * [33ma3cc88d[m mplibpreamble environment instead of simple command
[1;36m|[m * [33m1badcd9[m no \unexpanded in user preamble
[1;36m|[m * [33maa12596[m implemented \mplibpreamble
* [31m|[m   [33m87db82e[m Merge pull request #5 from dohyunkim/master
[32m|[m[31m\[m [31m\[m  
[32m|[m [31m|[m[31m/[m  
[32m|[m * [33me77087c[m wrong baseline of textext box
[32m|[m[32m/[m  
*   [33me14235b[m Merge pull request #4 from phi-gamma/master
[34m|[m[35m\[m  
[34m|[m * [33m864159a[m comment trailing eol in LaTeX test
* [35m|[m   [33m7fbdb82[m Merge pull request #2 from phi-gamma/master
[36m|[m[35m\[m [35m\[m  
[36m|[m [35m|[m[35m/[m  
[36m|[m * [33m940c7ad[m Updating TODO
[36m|[m * [33m8ab7bd2[m Remove unneccessary dependencies
[36m|[m * [33meab41d2[m Adding a little more doc
[36m|[m * [33m5e9c09a[m Adding a test in plain too
[36m|[m * [33m02730f1[m Removing dead code from the old environment
[36m|[m * [33mb4cec06[m Document changes by Kim in the context code
[36m|[m * [33macd0bc3[m Readme update
[36m|[m * [33m1ad7746[m GPLv2 instead of CC0
[36m|[m * [33m4f1be99[m Minor doc update
[36m|[m * [33m333e511[m Minor dtx fix
[36m|[m * [33ma3a03c0[m Update doc style and Makefile (pdflatex -> lualatex)
[36m|[m * [33mfc11100[m A few more locals
[36m|[m * [33m12643df[m Using luatexbase info, log and err
[36m|[m * [33m37d6401[m Add test file for LaTeX
[36m|[m * [33m0736d9f[m Fixing minor errors
[36m|[m * [33mc3950c2[m use mplib catcodes for both Latex and Plain
[36m|[m * [33me08e168[m fix missing upvalues
[36m|[m * [33ma4c9bd8[m import Kim’s patch to luatex-mplib.tex
[36m|[m * [33m36b31ae[m import Kim’s patch to luatex-mplib.lua
[36m|[m * [33m6c9f5e2[m keep % as comment char
[36m|[m * [33m67d5417[m sync with current luatex-mplib as of 2013-05-07
[36m|[m[36m/[m  
* [33maeb2380[m 1.09
* [33m2acbb2b[m Apply patch by Paul Vojta, fixing spurious spaces.
* [33m94d5d08[m Add test file for spurious spaces.
* [33m366c021[m don't git-ignore test files, not generated here
* [33m209aa02[m Make: clean more thoroughly
* [33md41326c[m update todo
* [33m8271a0d[m Bump version for bugfix release.
* [33mce98ddf[m Fix bug with some characters in {luamplib}.
* [33m6e8471b[m fix Makefile
* [33m130e879[m Bump version and update NEWS.
* [33mac37021[m dump a few ideas in a todo file
* [33m1e3cee4[m Rm mem files support.
* [33mec5e2a5[m No need to repeat the namespace all over the place
* [33m36708be[m rationalize error functions
* [33m688b66a[m gitignore a few files
* [33me2e8815[m Makefile: add a "check" target!
* [33m5bf11ef[m Change author/maint/contact info.
* [33m6a112d8[m fix make clean & typo in readme
* [33m47a432c[m update support adress
* [33m0589dea[m version & news
* [33m77a123a[m Bugfix per Hans.
* [33ma61b0ad[m Adapt to luatexbase v0.3. Now v1.05.
* [33me2addb8[m bumping date and version number
* [33m4738e08[m adding two test files
* [33mc4a735c[m fixing a bug in LaTeX's detection
* [33m5aaeb7d[m renaming the .mem file into mplib-luatex.mem, which should be present in TeXLive 2010.
* [33m9bd9429[m replacing luadirect by directlua
* [33m5ad7ee6[m Adding a NEWS file
* [33mb61538e[m Using the new luatexbase system and bumping version
* [33mc2c43a6[m A very french typo
* [33m02dc8f2[m adapting luamplib to TeXLive 2009, the .mem file is no longer needed (though used in TeXLive 2009)
* [33mc05d9c9[m very small adaptation to the new luatextra
* [33m06e0753[m Update URI in the Readme.
* [33m126ba5f[m Minimale code reformating.
* [33mcb10fa7[m Rename TEXMF to TEXMFROOT in Makefile.
* [33md2c0a94[m New target `install TEXMF=/path/to/root'.
* [33mc44d4d3[m Fix the `manifest' target.
* [33me3cde74[m Luamplib's README: install, manifest, licence.
* [33m79af410[m Makefile's: new 'manifest' target.
* [33md602d78[m Makefile: adapt CTAN distribution, clean up.
* [33ma28a3e3[m harmonizing the version numbers and dates (sometimes several were present in the .dtx
* [33m911f6ac[m Packaging: no .drv, Makefile with a 'ctan' target.
* [33m23c342b[m adding the README files for some packages
* [33m94254cc[m loading luaotfload by default in pdf mode, adding a missing ProvidesPackage in luamplib, and precising an error
* [33m733b00c[m some small code formatting, and copyright clarification on luainputenc.sty
* [33m7e7c67e[m first working version of luainputenc, and directlua0 renaming in luamplib
* [33m711e324[m first working version of luaminimalotf and minimal corrections in luamplib
* [33md927dd3[m a first working version of luamplib
* [33m85410ad[m An extra function for luatextra.lua, a dirty bug fix, and almost finishing luamplib.
* [33mcbb73e0[m commit of the current state of the packages
\end{verbatim}
}
\end{document}

答案2

有一些工具可以自动完成这个转换过程。我更喜欢ansifilter

要使用ansifilter,首先,按照说明进行安装这里

现在,通过管道传输感兴趣的命令ansifilter。对于您的示例,您可以运行:

git log --color --graph --oneline | ansifilter --latex > log.tex

结果log.tex是与 LaTeX 兼容的,具有适当的颜色。例如: 在此处输入图片描述

ansifilter如果您想使用自定义颜色,还支持颜色图。请参阅手册:https://gitlab.com/saalen/ansifilter#user-content-color-mapping

相关内容