LaTeX Tutorial

To crop an image in LaTeX, you can use the adjustbox package or the graphicx package with the trim option. Here’s how you can do it:

Method 1: Using the adjustbox Package

\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{graphicx}

\begin{document}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.8\textwidth, height=0.5\textheight, frame, trim={left bottom right top}, clip]{example-image}
    \caption{Cropped Image using adjustbox}
    \label{fig:cropped}
\end{figure}

\end{document}

Method 2: Using the graphicx Package

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}[h]
    \centering
    \includegraphics[trim={left bottom right top},clip,width=0.8\textwidth]{example-image}
    \caption{Cropped Image using graphicx}
    \label{fig:cropped}
\end{figure}

\end{document}

Explanation of the trim Option

The trim option specifies the amount to trim from the respective sides of the image:

For example, to trim 1 inch from the left, 0.5 inch from the bottom, 1 inch from the right, and 0.5 inch from the top, you would write:

trim={1in 0.5in 1in 0.5in}

To resize an image, you can specify the width and/or height:

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.5\textwidth]{example-image}
    \caption{Resized Image}
    \label{fig:resized}
\end{figure}

\end{document}

You can use the subfigure package or the subcaption package for this:

Using the subfigure Package

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfigure}

\begin{document}

\begin{figure}[h]
    \centering
    \subfigure[First Image]{\includegraphics[width=0.45\textwidth]{example-image-a}}
    \subfigure[Second Image]{\includegraphics[width=0.45\textwidth]{example-image-b}}
    \caption{Two Images in One Figure using subfigure}
    \label{fig:subfigures}
\end{figure}

\end{document}

Using the subcaption Package

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure}[h]
    \centering
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example-image-a}
        \caption{First Image}
    
    \caption{Two Images in One Figure using subcaption}
    \label{fig:subcaptions}

You can add a border using the adjustbox package:

\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{graphicx}

\begin{document}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.5\textwidth, frame]{example-image}
    \caption{Image with Border}
    \label{fig:border}
\end{figure}

\end{document}

You can add a shadow using the tcolorbox package:

\documentclass{article}
\usepackage{graphicx}
\usepackage{tcolorbox}

\begin{document}

\begin{figure}[h]
    \centering
    \tcbset{width=0.5\textwidth, boxrule=0pt, colframe=white, colback=white, boxshadow=0.5mm}
    
        
    

\end

You can rotate an image using the graphicx package:

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}[h]
    \centering
    \includegraphics[angle=45,width=0.5\textwidth]{example-image}
    \caption{Rotated Image}
    \label{fig:rotated}


\end

You can use the duckuments package to include a placeholder image:

\documentclass{article}
\usepackage{duckuments}

\begin{document}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.5\textwidth]{example-duck}
    \caption{Placeholder Image}
    \label{fig:placeholder}


\end