我試圖將圖像包裹在linguex
項目符號中,但圖像無法編譯。
\documentclass{article}
\usepackage{linguex, graphicx, wrapfig}
\begin{document}
\ex. bla bla bla \begin{wrapfigure}{r}{0.5\textwidth}\includegraphics[width=0.5\textwidth]{image}\end{wrapfigure}
\end{document}
請注意,我需要wrapfigure
環境與參數位於同一行\ex.
,否則它將無法編譯。我覺得這兩個包之間存在某種不相容性,但有人知道是否有解決方法?
謝謝!
答案1
有一些解決方案可以將圖形放置在清單環境中。以下使用此處發布的答案:是否可以在枚舉或逐項環境中使用wrapfig?
\ex
唯一的差別是宏與環境的使用enumerate
。引用參考解決方案:
可以透過將 放入
wrapfigure
aparbox
或 中,minipage
如該問題的一些重複項中提到的那樣。然而,這些方法通常透過手動插入\vspace
手動選擇的值來解決垂直間距問題。該解決方案透過使用支柱(\strut
)自動工作。支柱將第一個文字行的基線放置在距 .txt 檔案頂部指定的距離處minipage
。然後adjustbox
用於將恰好該數量的頂部放置minipage
在外部基線之上。
MWE及結果如下:
\documentclass[a4paper,12pt]{article}
\usepackage{linguex, graphicx, wrapfig}
\usepackage[margin=3cm]{geometry}
\usepackage{lipsum}
\usepackage{adjustbox}
\usepackage{capt-of}
\newlength{\strutheight}
\settoheight{\strutheight}{\strut}
\begin{document}
% From https://tex.stackexchange.com/questions/59101/will-it-ever-be-possible-to-use-wrapfig-with-an-enumerate-or-itemize-environment/309454#309454
\ex. \begin{adjustbox}{valign=T,raise=\strutheight,minipage={1.0\linewidth}}
\begin{wrapfigure}{r}{0.5\linewidth}
\centering
\includegraphics[width=0.5\linewidth]{example-image-a}
\captionof{figure}{My caption}
\end{wrapfigure}%
\strut{}\lipsum[2]
\end{adjustbox}
\end{document}
編輯
這是對OP評論的回應:
那麼是否可以將一個圖形包裹在多個 \ex 中。環境?
我必須猜測才能解釋所要求的內容。這是在不同層次的環境下用多個數字進行的解釋。
這是代碼:
\documentclass[a4paper,10pt]{article}
\usepackage{linguex, graphicx, wrapfig}
\usepackage[margin=3cm]{geometry}
\usepackage{lipsum}
\usepackage{adjustbox}
\usepackage{capt-of}
\newlength{\strutheight}
\settoheight{\strutheight}{\strut}
\begin{document}
% From https://tex.stackexchange.com/questions/59101/will-it-ever-be-possible-to-use-wrapfig-with-an-enumerate-or-itemize-environment/309454#309454
\ex. \lipsum[2]
\a. \begin{adjustbox}{valign=T,raise=\strutheight,minipage={1.0\linewidth}}
\begin{wrapfigure}{r}{0.5\linewidth}
\centering
\includegraphics[width=0.5\linewidth]{example-image-a}
\captionof{figure}{My caption}
\end{wrapfigure}%
\strut{}\lipsum[2]
\end{adjustbox}
\b. \begin{adjustbox}{valign=T,raise=\strutheight,minipage={1.0\linewidth}}
\begin{wrapfigure}{r}{0.5\linewidth}
\centering
\includegraphics[width=0.5\linewidth]{example-image-a}
\captionof{figure}{My caption}
\end{wrapfigure}%
\strut{}\lipsum[2]
\end{adjustbox}
\a. \begin{adjustbox}{valign=T,raise=\strutheight,minipage={1.0\linewidth}}
\begin{wrapfigure}{l}{0.5\linewidth}
\centering
\includegraphics[width=0.5\linewidth]{example-image-a}
\captionof{figure}{My caption}
\end{wrapfigure}%
\strut{}\lipsum[2]
\end{adjustbox}
\b.\lipsum[2]
\end{document}