Search code examples
python-sphinxrestructuredtext

How to remove the box around the code-block in reStructuredText with sphinx


I am using restructured text to document something. To use directive "code-block", the code seems always to be contained in a box in the generated document. For example,

     .. code-block:: C++
        :linenos:
        :emphasize-lines: 2

        void readIntegerFile(const string& fileName, vector<int>& dest)
            throw(invalid_argument, runtime_error)
        {
            // some code ...
        }

The C++ code is alway boxed in generated PDF file. I am wondering if there is a knob to turn off the box. I googled around and can't find it. In fact, I can't even find the full list of knobs of code-block

Thanks


Solution

  • Add the following code to your conf.py file

    latex_elements = {
        'sphinxsetup': 'verbatimwithframe=false',
    }
    

    This will work no matter what your background color is