2

I am typing my thesis in LaTeX and I have problems with captions. In my thesis are pictures as well as graphs. According to my school I have to have these captions: picture: "Obr. XXX", graph: "Graf. XXX".

I use Czech babel.

Pictures are displayed correctly, but how can I change this caption when I include graph as a picture? I have tried \newcommand as well as \renewcommand but with these commands I have changed all captions from pictures to graphs.

Edit: example of my code:

\documentclass[a4paper,12pt, hidelinks]{report}

\usepackage[czech]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
...

\begin{document}
\begin{figure}[H]
\centering
\includegraphics[scale=1]{figure}
\caption{This is figure. Caption should be "Obr. 1 This is figure."}
\label{fig:figure}
\end{figure}

\begin{figure}[H]
\centering
\includegraphics[scale=1]{graph}
\caption{This is graph. Caption should be "Graf. 1 This is graph."}
\label{fig:graph}
\end{figure}
\end{document}
4
  • Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. I suspect some solution with the caption package, however.
    – user31729
    Commented Apr 6, 2015 at 21:21
  • I've added MWE as well as corrected my anwer. In my real document I have loaded many packages as well as some settings but I hope, you will see from MWE where is my problem.
    – astrak
    Commented Apr 6, 2015 at 21:36
  • Must graphs and pictures be numbered independently?
    – Bernard
    Commented Apr 6, 2015 at 21:55
  • Yes, unfortunately, they must.
    – astrak
    Commented Apr 7, 2015 at 6:11

1 Answer 1

4

You can use the newfloat package to create a floating environment graph for graphs.

MWE

\documentclass[a4paper,12pt, hidelinks]{report}
\usepackage[czech]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{mwe} % for 'example-image'
\usepackage{newfloat}
\DeclareFloatingEnvironment{graph}
\addto\captionsczech{%
  \renewcommand{\graphname}{Graf.}%
  \renewcommand{\figurename}{Obr.}%
}

\begin{document}
\begin{figure}[H]
\centering
\includegraphics[scale=1]{example-image}
\caption{This is figure. Caption should be "Obr. 1 This is figure."}
\label{fig:figure}
\end{figure}

\begin{graph}[H]
\centering
\includegraphics[scale=1]{example-image}
\caption{This is graph. Caption should be "Graf. 1 This is graph."}
\label{fig:graph}
\end{graph}
\end{document}

Output

enter image description here

2
  • This is great and elegant solution. I've never heard about newfloat package... It works perfectly, thank you so much!
    – astrak
    Commented Apr 7, 2015 at 6:10
  • How would one do the same thing, but for tables? For example, I want to have one table caption be "Supp. Table" and another "Comp. Table". Commented Dec 2, 2017 at 20:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .