kks32 / phd-thesis-template

A LaTeX / XeLaTeX / LuaLaTeX PhD thesis template for Cambridge University Engineering Department (CUED)
http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/ThesisStyle/
MIT License
831 stars 400 forks source link

SVG files for in Chapter2/figs/vector/* is not recognised #167

Open mxochicale opened 6 years ago

mxochicale commented 6 years ago

For some reason when using fig.svg file in Chapter2.tex

\begin{figure}[htbp!]
\centering
\includegraphics[width=1.0\textwidth]{fig}
\caption[Minion]{This is just a figure caption}
\label{fig:minion}
\end{figure}

with images in the right path

/phd-thesis/chapter2/figs$ tree
.
├── raster
│   └── WallE.png
└── vector
    ├── fig.svg
    ├── WallE.eps
    └── WallE-eps-converted-to.pdf

I got this error after using make:

Makefile:2824: thesis.d: No such file or directory
= thesis.tex --> thesis.d thesis.pdf.1st.make (0-1) =
make: *** No rule to make target 'fig', needed by 'thesis.d'. Stop.

I checked the Makefile (version := 2.2.1-alpha10) and it seems fine and tried with eps files and the making works well.

Any suggestions?

kks32 commented 6 years ago

Have you looked at this: https://tex.stackexchange.com/questions/2099/how-to-include-svg-diagrams-in-latex?

mxochicale commented 6 years ago

Thanks for the reference but I am not using LaTex compiler to create SVG files. Makefile has the following rule:

# Converts svg files into .eps files
#
# $(call convert-svg,<svg file>,<eps/pdf file>,[gray])
convert-svg = $(INKSCAPE) --without-gui $(if $(filter %.pdf,$2),--export-pdf,--export-eps)='$2' '$1'

for the purpose of the conversion from svg to PDF. However, make output is the following:

$ make
make: *** No rule to make target 'drawing', needed by 'thesis.d'. Stop

and some output in "thesis.d" said the following

 90 .SECONDEXPANSION:
 91 # MISSING stem "drawing" - allowed extensions are ".png,.jpg,.pdf,.eps" - leave comment here - it affects the build
 92 -include drawing.gpi.d

From Makefile, I found that Holger Nahrstaedt is the last maintainer of Makefile and so I create an issue https://github.com/holgern/TUB_PhDThesisTemplate/issues/2 asking the same question.

For the time being, what it is working for me when using SVG files is following command typed in the terminal:

inkscape --export-pdf PDF/thesis-structure.pdf vector/drawing.svg

I appreciate any help that you can provide!

clbarnes commented 5 years ago

A bit old, but for anyone who comes across this in the future:

I understand that inkscape sometimes rasterises stuff you don't want it to, and as such I personally use rsvg-convert to convert SVGs into PDFs as per this answer. In my repo I have a scripts directory, which includes this script:

#!/bin/bash

set -e

ROOT_PATH=$1

for SVG_PATH in $(find ${ROOT_PATH} -iname "*.svg" | grep -vP "CollegeShields/")
do
    PDF_PATH="${SVG_PATH%.svg}.pdf"
    if [ ! -f "${PDF_PATH}" ] || [ "${SVG_PATH}" -nt "${PDF_PATH}" ]; then
        echo "converting ${SVG_PATH} to PDF"
        rsvg-convert -f pdf -o ${PDF_PATH} ${SVG_PATH}
    else
        echo "don't need to convert ${SVG_PATH}"
    fi
done

It looks for any file ending with .svg which isn't below the CollegeShields directory, then if that SVG doesn't have a PDF of the same name in the same directory, or it does but the SVG file is newer than the PDF, the conversion is done.

Then in my makefile:

.PHONY: svg-convert
svg-convert:
    ./scripts/svg-convert.sh .

then I add svg-convert as a dependency of the all and all-pdf recipes.