Giter Site home page Giter Site logo

Problem with caption about minted HOT 9 CLOSED

gpoore avatar gpoore commented on July 24, 2024
Problem with caption

from minted.

Comments (9)

gpoore avatar gpoore commented on July 24, 2024

Can you give a minimal example that causes the problem?

from minted.

metal3d avatar metal3d commented on July 24, 2024

I will do it in 1 or 2 hours. No problem.

from minted.

metal3d avatar metal3d commented on July 24, 2024

Ok, this is the test:

\documentclass[12pt]{book} % Default font size is 12pt, it can be changed here
\usepackage[utf8]{inputenc} 
\usepackage[OT1]{fontenc}
\usepackage[francais]{babel}
\usepackage[default]{sourcesanspro}
\usepackage{minted}
\newminted{go}{}
\begin{document}

\chapter{Exemple 1 with fig}

\section{A figure test}

Note the caption font

\begin{figure}[H]
\caption{This is a test}
\end{figure}

\section{A minted listing}

Check caption, font is not opensans, but TTF Times (not found on Linux that uses Nimbus Time)

\begin{listing}[H]
\begin{gocode}
var a int
\end{gocode}
\caption{A golang code}
\end{listing}
\end{document}

I compile this with:

latex -shell-escape test.tex

Resulting ps:

  • Figure 1.1 => good font (open sans)
  • Listing 1 => Times roman font (not good)

from minted.

metal3d avatar metal3d commented on July 24, 2024

I found a workaround for now:

\usepackage[font=small]{caption} 

Best display with:

\usepackage[font=small,labelfont=bf]{caption}

So, the only problem is that figures uses the document font, not minted listings.

from minted.

metal3d avatar metal3d commented on July 24, 2024

Note: I remove any other not embed Times Roman problem using:

\usepackage{pslatex} 

But the listing label remains if we don't use caption package

from minted.

gpoore avatar gpoore commented on July 24, 2024

The problem is that the listing float is created using the float package, which doesn't provide support for easily changing fonts. (To change fonts, you'd have to redefine some of the styles defined at the end of the package.) The solution would be to use the newfloat package, which is part of the caption bundle. But that may be problematic due to backwards compatibility issues. I will have to look into various options for dealing with this while still maintaining acceptable backwards compatibility.

from minted.

metal3d avatar metal3d commented on July 24, 2024

No problem, at this time I use the workarounds that I gave in my last comments (pslatex and caption option). But yes, that could be cool if you've got a natural fix :)

Anyway, thanks for your help

from minted.

metal3d avatar metal3d commented on July 24, 2024

BTW: I found why my document has got Times references... that was an eps file generated by graphviz...

from minted.

gpoore avatar gpoore commented on July 24, 2024

There is now a newfloat package option that uses newfloat rather than float to create the listing environment. This provides better compatibility with the caption package.

from minted.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.