
파일이 다른 위치에 있는 경우 경로를 어떻게 정의할 수 있나요?
나는 이것을 서문에서 쓸 것입니다.
\usepackage{graphicx}
그런 다음 그래픽을 업로드하기 위해 다음을 사용합니다.
\includegraphics{File.extension}
하지만 파일이 다른 위치에 있는 경우에는 어떻게 경로를 지정하고, 중앙에 배치하며, 텍스트를 어떻게 추가할 수 있나요?
답변1
마음의 동기화를 위해 다음과 같이 가정해 보겠습니다.
Current
기본 입력 파일은 (예를 들어) 라는 폴더에 있습니다 .- 폴더는
Current
이름이 지정된 폴더에 있습니다Parent
. - 다이어그램을 포함하는 폴더
diagrams
도 폴더에 있습니다Parent
. - 사진을 포함하는 이름의 폴더
photos
가 폴더에 있습니다Current
.
를 사용하면 \graphicspath
기본 입력 파일에서 참조하려는 사진과 다이어그램에 대한 경로를 선언할 수 있습니다. 각 경로는 으로 묶여야 {}
하며 로 끝나야 합니다 /
.
나머지는 명확해야합니다.
\documentclass{article}
\usepackage{graphicx}
\graphicspath{{photos/},{../diagrams/}}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=0.8\linewidth]{filename}% no need to specify the file extension
\caption{Karl's students }
\label{fig:Karlsstudents}
\end{figure}
\end{document}
답변2
일반적인 조언: 모든 그래픽 파일을 경로 바로 아래의 'picture' 하위 디렉토리에 넣으십시오. 그런 다음 다음을 사용하여 파일을 로드할 수 있습니다.
\includegraphics{./pictures/File.extension}
점 표기법을 사용하면 위의 디렉터리를 사용할 수도 있습니다. 다음 줄은 (TeX 파일이 있는 디렉터리에서) 한 디렉터리 수준 위로 이동한 다음 'myfiles/pictures' 디렉터리로 이동하여 'File.extension'을 사용합니다.
\includegraphics{../myfiles/pictures/File.extension}
TeX 파일과 그래픽 파일을 완전히 분리하는 것은 권장하지 않습니다. 모든 것을 함께 사용하면 문서 디렉토리를 훨씬 쉽게 이동할 수 있습니다.
답변3
현재 그림 설정을 사용하고 있습니다.
\begin{figure}[htbp]
\centering
\includegraphics[width = 0.8\textwidth]{path/figurefile}
\caption{Somecaption \label{fig:somelabel}}
\end{figure}
에서 \graphicspath{path}
생략할 수 있도록 서문에 지정하는 것도 가능합니다 . LaTeX는 에서 검색 하지만 의 하위 폴더는 검색하지 않으므로 에서 지정해야 합니다 .path/
includegraphics
figurefile
path
path
\includegraphics