將文字放在圖像旁邊

將文字放在圖像旁邊

我正在關注這裡給出的解決方案嘗試獲得這種效果: 在此輸入影像描述

但這個解決方案並不成功。這是下面給出的程式碼的輸出:

在此輸入影像描述

您能幫我讓文字顯示在數字旁邊嗎,如上面第一張圖片所示?

這是我到目前為止的程式碼:

\documentclass{article}
\usepackage{graphicx}

\newcommand*{\authorimg}[1]{%
  \raisebox{-.3\baselineskip}{%
    \includegraphics[
      height=\baselineskip,
      width=\baselineskip,
      keepaspectratio,
    ]{#1}%
  }%
}

\begin{document}
\begin{itemize}
\item[\authorimg{example-image-a}] FONTS\\The range of fonts on your\\
computer is often highly distinctive\\(unless you only have the fonts\\the machine came with)
\item[\authorimg{example-image-b}] SCREEN SIZE\\Though easily switched, this\\setting can be a useful aspect of\\your devices's fingerprint
\end{itemize}
\end{document}

答案1

像這樣的東西嗎?

字體

\documentclass[]{article}
\usepackage{graphicx,array}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}
    \begin{tabular}{C{2.8cm}  L{5.5cm}}
        \includegraphics[width=\linewidth]{example-image-a} & FONTS \newline 
        The range of fonts on your computer is often highly distinctive (unless you only have the fonts the machine came with) \\
        \includegraphics[width=\linewidth]{example-image-a} & SCREEN SIZE \newline 
        Though easily switched, this setting can be a useful aspect of your device's fingerprint \\
        \includegraphics[width=\linewidth]{example-image-a} & SOFTWARE \newline 
        Do you have an art director's toolkit or are you an unrepentant gamer? Or both?
    \end{tabular}
\end{document}

我固定了兩列的寬度,以便重現與您所擁有的類似的內容,參考解決方案這裡。這些允許透過手動換行\newline,這就是我用來從等換行的方式FONTS

答案2

在此輸入影像描述

miniage僅在第一項中使用:

\documentclass{article}
\usepackage{graphicx}

\newcommand*{\authorimg}[1]{%
  \raisebox{-.3\baselineskip}{%
    \includegraphics[
      height=\baselineskip,
      width=\baselineskip,
      keepaspectratio,
    ]{#1}%
  }%
}

\begin{document}
\begin{itemize}
\item[\authorimg{example-image-a}] \begin{minipage}{\dimexpr\linewidth-2\baselineskip\relax}
                                    FONTS\\The range of fonts on your\\
                                    computer is often highly distinctive\\
                                    (unless you only have the fonts\\
                                    the machine came with)
                                    \end{minipage}
\item[\authorimg{example-image-b}] SCREEN SIZE\\Though easily switched, this\\setting can be a useful aspect of\\your devices's fingerprint
\end{itemize}
\end{document}

附錄:要獲得更大的圖像,您需要

  • 定義更大labelwidth(該圖像在標籤中有空間)
  • 影像尺寸適應標籤寬度

例如,圖像大小應等於4\baselineskip您可以在 MWE 上更改,如下所示:

\documentclass{article}
\usepackage{graphicx}
\usepackage{enumitem}

\newcommand*{\authorimg}[1]%
    { \raisebox{-1\baselineskip}{\includegraphics[width=\imagesize]{#1}}}
\newlength\imagesize    % new lwngth for determining image size and label width

\begin{document}
\begin{itemize}[leftmargin=1.2\imagesize,labelwidth=\imagesize]% left margin is 20% bigger than label width
    \setlength\imagesize{4\baselineskip}
\item[\authorimg{example-image-a}] \begin{minipage}{\dimexpr\textwidth-1.2\imagesize\relax}
                                    FONTS\\
                                    The range of fonts on your\\
                                    computer is often highly distinctive\\
                                    (unless you only have the fonts\\
                                    the machine came with)
                                    \end{minipage}
\end{itemize}
\end{document}

在此輸入影像描述

相關內容