我想营造一种笔记粘在页面顶部的错觉。这里我在 Photoshop 中输入并保存了
然后将其添加到 xeLatex 文档,其中\includegraphics[angle =30 ]{paper.png}
paper.png 位于http://www.bluehillsfarm.com/images/paper.png
我希望能够将便签上的注释输入到 TeX 中并使其自动调整大小,即如果教授的注释较长,它将缩小为较小的字体以适合相同大小的便签。这是我的 MWE,但注释未正确放置在便签上。
\documentclass{article}
\usepackage{graphicx,pstricks}
\newpsstyle{gridstyle}
{
gridwidth=0.1pt,
subgridwidth=0.05pt,
gridlabels=5pt,
gridcolor=green,
subgridcolor=white,
subgriddiv=2
}
\psset{style=gridstyle}
\newsavebox\IBox
% Ratio of the imported graphics width to the line width.
\def\RatioToLineWidth{0.95}
\savebox\IBox
{%
\includegraphics[width=\RatioToLineWidth\linewidth]{paper.png}%
}
\newdimen\width
\newdimen\height
\width=\wd\IBox
\height=\ht\IBox
\pagestyle{empty}
\begin{document}
\psset
{
xunit=0.1\width,
yunit=0.1\height
}
\begin{pspicture}(\width,\height)
\rput[lb](0,0){\usebox\IBox}
{\parbox{4cm}{I want this text to be justified. I want this text to be justified. I want this text to be justified. I want this text to be justified. I want this text to be justified. I want this text to be justified. }}
\end{pspicture}
\end{document}
答案1
这里我使用嵌套的\stackinset
s,使用OP提供的纸质图像和收到的邮票http://www.xpressmarking.co.za/wp-content/uploads/2015/01/Received-Trodat-S-Printy.png
\documentclass{article}
\usepackage{stackengine,graphicx,lipsum}
\begin{document}
\rotatebox{30}{%
\stackinset{c}{}{c}{-.1cm}{\parbox{3in}{\bfseries\scriptsize\sffamily\lipsum[4]}}{%
\stackinset{r}{2cm}{t}{1.5cm}{\includegraphics[width=1in]{Received-Trodat-S-Printy}}{%
\includegraphics[width=4in]{paper}}}}
\end{document}
答案2
如果你愿意TikZ
方法,有一种可能性:
代码:
\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage{tikz}
\usepackage{environ}
\usepackage{lipsum}
\newdimen\fontdim
\newdimen\upperfontdim
\newdimen\lowerfontdim
\newif\ifmoreiterations
\fontdim12pt
\makeatletter
\NewEnviron{fitbox}[2]{% \begin{fitbox}{<width>}{<height>} stuff \end{fitbox}
\def\buildbox{%
\setbox0\vbox{\hbox{\minipage{#1}%
\fontsize{\fontdim}{1.2\fontdim}%
\selectfont%
\stuff%
\endminipage}}%
\dimen@\ht0
\advance\dimen@\dp0
}
\def\stuff{\BODY}% Store environment body
\buildbox
% Compute upper and lower bounds
\ifdim\dimen@>#2
\loop
\fontdim.5\fontdim % Reduce font size by half
\buildbox%
\ifdim\dimen@>#2 \repeat
\lowerfontdim\fontdim
\upperfontdim2\fontdim
\fontdim1.5\fontdim
\else
\loop
\fontdim2\fontdim % Double font size
\buildbox%
\ifdim\dimen@<#2 \repeat
\upperfontdim\fontdim
\lowerfontdim.5\fontdim
\fontdim.75\fontdim
\fi
% Now try to find the optimum size
\loop
%\message{Bounds: \the\lowerfontdim\space
% \the\fontdim\space \the\upperfontdim^^J}
\buildbox%
\ifdim\dimen@>#2
\moreiterationstrue
\upperfontdim\fontdim
\advance\fontdim\lowerfontdim
\fontdim.5\fontdim
\else
\advance\dimen@-#2
\ifdim\dimen@<10pt
\lowerfontdim\fontdim
\advance\fontdim\upperfontdim
\fontdim.5\fontdim
\dimen@\upperfontdim
\advance\dimen@-\lowerfontdim
\ifdim\dimen@<.2pt
\moreiterationsfalse
\else
\moreiterationstrue
\fi
\else
\moreiterationsfalse
\fi
\fi
\ifmoreiterations \repeat
\box0% Typeset content
}
\makeatother
\newsavebox\ImageBox
\savebox\ImageBox{\includegraphics[width=0.6\linewidth]{paper}}
\newcommand\MyNote[2][]{%
\begin{tikzpicture}[#1]
\node[inner sep=0pt,outer sep=0pt,anchor=north west] (image)
{\usebox\ImageBox};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[anchor=north west,inner sep=0pt] at ([shift={(0.065,-20pt)}]image.north west)
{\begin{fitbox}{0.6\wd\ImageBox}{.6\ht\ImageBox}
#2
\end{fitbox}};
\end{scope}
\end{tikzpicture}%
}
\begin{document}
\noindent\MyNote{Some short text}
\noindent\MyNote[rotate=30,transform shape]{Some test text and here we add some more text to see what is happening with the font size }
\noindent\MyNote{Some test text and here we add some more text to see what is happening with the font size and here we add some more text to see what is happening with the font size and here we add some more text to see what is happening with the font size and here we add some more text to see what is happening with the font size and here we add some more text to see what is happening with the font size}
\end{document}
为了让字体调整大小,我使用了Werner's answer
到通过调整字体大小使文本适合给定的框
答案3
\documentclass{article}
\usepackage{pstricks-add}
\usepackage{graphicx}
\usepackage{lipsum}
\newsavebox\IBox
\sbox\IBox{\includegraphics{paper}}
\makeatletter
\def\setPaper{\@ifnextchar[\setPaper@i{\setPaper@i[0]}}
\def\setPaper@i[#1](#2,#3)#4{\rput{#1}(#2,#3){%
\usebox\IBox\psTextFrame[linestyle=none](-\wd\IBox,0)(0,\ht\IBox){%
\parbox{0.7\wd\IBox}{#4}}}}%
\makeatother
\begin{document}
\setPaper(3,-3){\lipsum[1]}
\setPaper[45](0.5\linewidth,-12cm){\lipsum[1]}
\end{document}