Bonjour,
Je souhaiterais encadrer mes codes à l'aide du package tcolorbox de sorte que le cadre ait la largeur du code qu'il contient. Je sais que le package propose le mode de capture hbox pour faire cela et ça fonctionne très bien avec listings:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 \documentclass[a4paper,oneside,12pt]{article} \usepackage{tcolorbox} \tcbuselibrary{listings,skins} \begin{document} % Boite de couleur standard, de largeur ajustée à la taille du code \begin{tcblisting}{listing only, hbox} from math import sin, exp def Suite(n): U = 3 for k in range(n): U = sin(U)+1/(exp(U)+1) return U # Exemple Suite(13) \end{tcblisting} \end{document}
Mais avec minted, ça se gâte:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 \documentclass[a4paper,oneside,12pt]{article} \usepackage{tcolorbox} \tcbuselibrary{minted,skins} \begin{document} % Boite de couleur standard avec minted, sans hbox (fonctionne) \begin{tcblisting}{listing only, minted style = emacs, minted language = python} from math import sin, exp # Sans hbox def Suite(n): U = 3 for k in range(n): U = sin(U)+1/(exp(U)+1) return U # Exemple Suite(13) \end{tcblisting} % Boite de couleur standard avec minted et hbox (ne fonctionne pas) \begin{tcblisting}{listing only, minted style = emacs, minted language = python, hbox} from math import sin, exp # Avec hbox def Suite(n): U = 3 for k in range(n): U = sin(U)+1/(exp(U)+1) return U # Exemple Suite(13) \end{tcblisting} \end{document}
Voici enfin le log d'erreurs:
Auriez-vous une idée de ce qui se passe et de comment y remédier?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 ! LaTeX Error: Something's wrong--perhaps a missing \item. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.1 ...dchars=\\\{\}, ,tabsize=2,fontsize=\small ] Try typing <return> to proceed. If that doesn't work, type X <return> to quit. ! LaTeX Error: Something's wrong--perhaps a missing \item. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.1 ...dchars=\\\{\}, ,tabsize=2,fontsize=\small ] Try typing <return> to proceed. If that doesn't work, type X <return> to quit. ! LaTeX Error: Something's wrong--perhaps a missing \item. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.12 \end{Verbatim} Try typing <return> to proceed. If that doesn't work, type X <return> to quit. ! LaTeX Error: Something's wrong--perhaps a missing \item. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.12 \end{Verbatim} Try typing <return> to proceed. If that doesn't work, type X <return> to quit. ) runsystem(del essaiMintedTcolor.out.pyg)...executed. Overfull \hbox (3913.37741pt too wide) in paragraph at lines 33--33
Partager