I prefer to use LaTeX packages for a configuration similar to this: Tex StackExchange has a large community that has developed methods for loading such issues.
The floatrow package can be used to change the title above the picture. This is pretty much based on this previous answer .
Using R Markdown, since this is the most commonly used workflow these days, the package can be downloaded by including the header-includes include argument in YAML, as shown below:
--- output: pdf_document header-includes: - \usepackage{floatrow} - \floatsetup[figure]{capposition=top} --- '''{r fig.cap="cap, cap, and cap"} plot(1) '''
The output has the desired order, first the code is displayed, then the signature and the schedule.

If the code is not needed, the echo=FALSE parameter can be added to the chunk header.
source share