Yan Zhu
Yan Zhu

Reputation: 4346

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

Upvotes: 3

Views: 1221

Answers (2)

CPetkoWork
CPetkoWork

Reputation: 26

Add the following code to your conf.py file

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

This will work no matter what your background color is

Upvotes: 1

pdw
pdw

Reputation: 8866

The box seems to be hardcoded, but you can hide it by adding this command to latex_elements['preamble'] in the conf.py file:

\definecolor{VerbatimBorderColor}{rgb}{1,1,1}

This won't work very well if you don't have plain white background though.

Upvotes: 2

Related Questions