2

I'd like to have a function for a "letter". By letter I mean that it is a ruled paper, and the text looks justified, as if it would be without the "uline" function.

Moreover, the ulem package is not what I want, since the last line will always be short (any line that has a linebreak).

I am more thinking of something as in the exam class, the \fillwithlines order.

Anyone has an idea? Thanks in advance!

\documentclass[fontsize=9pt,twoside, DIV=calc]{scrbook}
\usepackage[papersize={12.5cm,19cm},inner=10mm, outer=10mm, bottom=13mm, top=10mm, footskip=6mm]{geometry}
\usepackage[T1]{fontenc}
 \usepackage[utf8]{inputenc} 
 \usepackage[ngerman]{babel}
 \usepackage[]{lipsum}

 \usepackage{xcolor} 
\xdefinecolor{notiz}{RGB}{239,227,157}

\usepackage{tabularx}
\usepackage{tikz}
\usepackage{tikzsymbols}
\usepackage{varwidth}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.pathmorphing}

\usepackage{ulem}

\newcommand{\post}[1]{
                         \small
                          \begin{center}

                                \begin{tikzpicture}[pencildraw/.style={ %
                                    decorate,
                                    decoration={random steps,segment length=2pt,amplitude=1pt}
                                    } %
                                ]
                                \node[ preaction={fill=black,opacity=.5,% zeilenabstand=2.8,
                                          transform canvas={xshift=1mm,yshift=-1mm}},
                                          pencildraw,draw,fill=notiz,text width=.8\textwidth,
                                          inner sep=5mm] {\uline{#1}};
                                \end{tikzpicture} 

                          \end{center}
                          \normalsize
}

\begin{document}

\post{\lipsum[1]}

\end{document}

1 Answer 1

2

Find suitable ruled paper, such as http://www.wordmstemplates.com/wp-content/uploads/2015/08/lined-paper-template-9898.jpg, download the image and use that as the \includegraphics filename.

RULED TEXT BOX

Here I introduce \linedbox{<width>}{<content>}, which does not support page breaking. User parameters are shown at top of the MWE:

  1. \addedleftmargin left margin of the lined box (currently 20pt);

  2. \addedrightmargin right margin of the lined box (currently 20pt);

  3. \scaledheight the scaled paper height. Used to match the paper's rule spacing with that of your fontsize (currently 6.98in);

  4. \scaledwidth the scaled paper width. It should be at least as large as the widest box you intend to make (it's value will affect the apparent width of the red line and the left margin size) (currently \textwidth);

  5. \naturalindent the natural left indent of the scaled paper, typically to a point just right of the red line (currently 15% of \scaledwidth).

  6. \topdiscard that amount of unruled paper at the top of the scaled image to discard (currently 10% of \scaledheight); and

  7. \topbottomgap vertical gap added above and below the ruled box (currently 1pt).

Here is the MWE

\documentclass{article}
\usepackage{graphicx,stackengine,trimclip}
\usepackage{lipsum}
\def\addedleftmargin{20pt}% LEFT MARGIN OF RULED BOX
\def\addedrightmargin{20pt}% RIGHT MARGIN OF RULED BOX
\def\scaledheight{6.98in}% ADJUST FOR DIFFERENT FONT SIZES
\def\scaledwidth{\textwidth}% SHOULD BE SET AT LEAST AS WIDE AS WIDEST USAGE
\def\naturalindent{.15\dimexpr\scaledwidth\relax}% BASED ON PAPER'S RED LINE LOCATION
\def\topdiscard{.10\dimexpr\scaledheight\relax}% UNRULED TOP OF PAPER TO THROW AWAY
\def\topbottomgap{1pt}% GAP ADDED ABOVE/BELOW RULED BOX
\def\reducedindent{\dimexpr\naturalindent-\addedleftmargin\relax}% CALCULATED QUANTITY
\newcommand\linedbox[2]{\noindent\savestack\pagetext{\begin{minipage}[b]{%
      \dimexpr#1-\naturalindent+\reducedindent-\addedrightmargin}%
    \strut#2\strut
    \end{minipage}%
  }%
  \addstackgap[\topbottomgap]{\stackinset{r}{\addedrightmargin}{t}{1pt}{\pagetext}%
  {\clipbox{%
    \reducedindent{} 
    \dimexpr\scaledheight-\topdiscard-\ht\pagetextcontent-\dp\pagetextcontent\relax{} 
    \dimexpr\scaledwidth-\dimexpr#1\relax-\reducedindent\relax{} 
    \topdiscard%
  }%
  {\includegraphics[height=\scaledheight,width=\scaledwidth]{lined-paper-template-9898}}}}%
}
\begin{document}
\lipsum[1]
{\centering\linedbox{4.3in}{\lipsum[1]Hi Mom!!}\par}
Or this: \linedbox{2in}{This is a test of the emergency broadcasting system.  
This is only a test}
\end{document}

enter image description here

UNIVERSAL LINED PAPER

Note that geometry margins and \fontsize need to be altered to conform to the paper.

\documentclass{article}
\usepackage[margin=1.2in]{geometry}
\usepackage{everypage}
\usepackage{graphicx}
\usepackage{lipsum}
% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\everyxy[3]{%
 \AddEverypageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
  \raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{#3}}}}
\everyxy{0in}{11in}{\includegraphics[height=\paperheight,width=\paperwidth]{lined-paper-template-9898}}
\begin{document}
\fontsize{15pt}{18.8pt}\selectfont
\lipsum[1-3]
Hi Mom!!
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .