The code-MWE LaTeX package based on fancyvrb and tcolorbox
=======

The `codemwe` package is a LaTeX package for typesetting code examples together with their results and for generating MWE (Minimal Working Example) source files. It is developed with Expl3 and builds on fancyvrb, tcolorbox and related packages. Code can be typeset either by the original fancyvrb scheme, or with syntax highlighting provided by the `minted` package (enabled with the `minted` option, which requires `-shell-escape`).

The `codemwe` package provides four environments: the `example` environment typesets an example code box and its result box side by side (or stacked in the vertical mode) and automatically generates an independently compilable MWE file; the `example*` environment is the vertical-mode variant; the `texcode` environment typesets a code box only, without numbering or compilation; and the `ccode` environment is preset for C code, showing a code box only and generating a `.c` source file. Besides the environments, the `\codemweset` macro sets global default options, `\codemweNewBox` registers user-defined box environments, `\codemweNewLang` registers new language varieties for the transition phrases and structural comment words, and `\codemweNewBackend` registers new code backends (e.g. Python) beyond the built-in LaTeX and C backends.

At the same time, the `codemwe` package offers customization options for examples, including the typesetting mode, numbering and labels, result figures, result box, code backends, line numbers, syntax highlighting, etc. These can be configured through package options, environment options, or the `\codemweset` macro.

For further details and examples, please refer to the manual (in Chinese/English).

Contributing
------------

1. gitee repository:
   (1). repository: [code-mwe](https://gitee.com/nwafu_nan/codemwe)
   (2). Issues and PR: [issue](https://gitee.com/nwafu_nan/codemwe/issues) or [pull request](https://gitee.com/nwafu_nan/codemwe/pulls).

基于fancyvrb与tcolorbox的代码MWE排版LaTeX宏包
=======

`codemwe`是一个用Expl3开发、基于fancyvrb、tcolorbox等宏包的LaTeX宏包，用于排版示例代码及其运行结果，并自动生成可独立编译的MWE（Minimal Working Example）源文件。示例代码默认按原样排版，也可以使用`minted`选项改用minted宏包实现语法高亮（此时需以`-shell-escape`选项编译文档）。

`codemwe`宏包提供了四个环境：`example`环境以水平模式（左代码框、右结果框）或垂直模式（上代码框、下结果框）排版示例代码及其编译结果，并自动生成可独立编译的`MWE`文件；`example*`环境是垂直模式变体；`texcode`环境仅排版一个代码框，不编号、不编译示例代码；`ccode`环境面向C语言代码预置了相应选项，仅显示代码框并生成`.c`源文件。同时，宏包还提供`\codemweset`命令用于设置全局默认选项，`\codemweNewBox`命令用于注册用户自定义的盒子环境，`\codemweNewLang`命令用于注册过渡语与结构注释词的新语种，`\codemweNewBackend`命令用于注册内置LaTeX与C后端之外的新代码后端（如Python）。

同时，`codemwe`宏包还为示例排版提供了排版模式、编号与引用、结果图片、结果框、代码后端、行号、语法高亮等**功能**设置选项，可以通过宏包选项、环境选项对其进行设置，也可以通过`\codemweset`命令实现全局设置。

可以通过阅读宏包手册（中英文双语）以了解该宏包更多的使用细节和使用样例。

##  参与贡献
---------------------

1. gitee仓库:
    (1). 仓库地址: [code-mwe](https://gitee.com/nwafu_nan/codemwe)
    (2). Issues and PR: [issue](https://gitee.com/nwafu_nan/codemwe/issues) or [pull request](https://gitee.com/nwafu_nan/codemwe/pulls).

Copyright and Licence
---------------------

    Copyright (C) 2026 by Nan Geng <nangeng@nwafu.edu.cn>
    ----------------------------------------------------------------------

    This work may be distributed and/or modified under the
    conditions of the LaTeX Project Public License, either
    version 1.3c of this license or (at your option) any later
    version. This version of this license is in
       http://www.latex-project.org/lppl/lppl-1-3c.txt
    and the latest version of this license is in
       http://www.latex-project.org/lppl.txt
    and version 1.3 or later is part of all distributions of
    LaTeX version 2005/12/01 or later.

    This work has the LPPL maintenance status "maintained".

    The Current Maintainer of this work is Nan Geng.

    This package consists of codemwe.sty, codemwe.tex and README.md(this file),
                 and the derived files codemwe.pdf.
