読者です 読者をやめる 読者になる 読者になる

Error in including pdf figures with \includegraphics; no BoundingBox!

最近 TeX で文章を書いていて、pdf で作成したグラフを読み込もうとしたところ、bb ファイルをちゃんと作成してたはずが、

LaTeX Error: Cannot determine size of graphic in fig2.5.pdf (no BoundingBox).

というエラーに見舞われました。


いろいろと試行錯誤したのですが、結局ファイル名に "." が含まれていると正常に処理できない事が原因だったようです。今後は気をつけよう。


\documentclass{jsarticle}

\usepackage[dvipdfmx]{graphicx} 

\begin{document}

\begin{figure}[!htb]
\begin{center}
% \includegraphics[clip,width=0.95\textwidth]{fig2.5.pdf}
\includegraphics[clip,width=0.95\textwidth]{fig25.pdf}
\end{center}
\caption{
If "." is included in the filename, an error will occur;
{\bf LaTeX Error: Cannot determine size of graphic in fig2.5.pdf (no BoundingBox).}
}
\end{figure}

\end{document}

おまけ

require(ggplot2)

x <- seq(0, 7, length.out = 50)
y <- -(x - 3.5)^2 + rnorm(50, sd = 3)
fig25 <- data.frame(x=x, y=y)

kmg2_theme_bw <- function(base_size = 26, base_family = "Times") {

  mod <- list(
    axis.title.x = theme_text(family = base_family, size = base_size, vjust = -0.5),
    axis.title.y = theme_text(family = base_family, size = base_size, angle = 90,
      vjust = 0.25),
    axis.ticks.margin = unit(0.2, "cm"),
		legend.background = theme_blank(),
    legend.key = theme_rect(colour = "transparent", fill = "transparent",
      size = 0.5, linetype = 0),
    legend.text = theme_text(family = base_family, size = base_size * 0.6),
    legend.title = theme_text(family = base_family, face = "bold",
			size = base_size * 0.6, hjust = 0),
    legend.position = c(0.95, 0.95), legend.justification = c(1, 1),
    plot.title = theme_text(family = base_family, face = "bold",
			size = base_size * 0.9, vjust = 1.5),
    plot.margin = unit(c(1, 1, 1, 1.25), "lines")
  )
  modifyList(theme_bw(base_size = base_size, base_family = base_family), mod)

}

pdf("fig25.pdf")

p1 <- ggplot(fig25, aes(x = x, y = y)) +
  geom_point(size = 3) +
  stat_smooth(aes(linetype = "Lowess smooth"), span = 2/3, degree = 1,
    family = "symmetric", size = 1, fill = "blue", alpha = 0.1) + 
  labs(x = expression(italic(x)), y = expression(italic(y)), linetype = "") +
  kmg2_theme_bw() + 
  opts(legend.position = c(0.19, 0.99), legend.justification = c(0, 1))
print(p1)

dev.off()

embedFonts("fig25.pdf")