0

To make my lessons, I often use the \Pointilles macro that I've found here. I've built other macros based on this who allowed me to create two documents : my book and student's book. One of them is \ProfReponseLigne who used \Pointilles to make dotted lines if it is the student version or display the answer if it is the teacher one.

To make the two versions more coherent each other (vertical space and alignment), I want to keep the dotted lines produced by \Pointilles and displayed the answer on it. As suggested by this topic for exam.cls.

Question :

  • How can I change my \ProfReponseLigne to display answer on the dotted lines with same vertical spacing ?
  • Or is there another way to achieve the same goal ? (I know about \blank command but it's not dotted and I'm not able to make it usable out of solution environment.)

Goal :

  • Keep the same vertical spacing and number of lines between the two versions.

MWE Here is a compilable MWE and the definition of my macros I've got so far.

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{etoolbox}
\usepackage{multido}
\usepackage{lipsum}
\usepackage{xcolor}

%% Permet de différencier une version prof et une version élève
\newbool{studentversion}
\setbool{studentversion}{true}      %true for students' version 


%% Extract from : https://tex.stackexchange.com/questions/248451/how-to-create-multiple-dotted-lines
\newcommand{\Pointilles}[2][3]%
{%
    \par\nobreak
    \noindent\rule{0pt}{1.5\baselineskip}       % Provides a larger gap between the preceding paragraph and the dots
    \multido{}{#2}{\noindent\makebox[\linewidth]{\rule{0pt}{#1\baselineskip}\dotfill}\\}    % ... dotted lines ...
    %           \medskip                                    % Gap between dots and next paragraph
}

\newcommand{\ProfReponseLigne}[2][1]%
{%
    \ifbool{studentversion}%
    {%%True (donc version pour étudiant)
        \Pointilles[1.5]{#1}
    }%
    {%%False (donc version pour prof)
        \par
        \textcolor{red}{$\rightarrow$ #2}\dotfill\vspace{\baselineskip}\\
    }
}
\begin{document}
\section{My lessons}
What a wonderful document to exploit :
\begin{quote}
    \itshape
    \lipsum[1]
\end{quote}
What can we conclude :
\ProfReponseLigne[2]{My very very very very very very very very very very very very long answer.}

\end{document}

Edit : For now, I'm testing some solution relied on \dotuline{} command provided by ulem package but I encountered some trouble when I'm calling this solution with \SI{}{} provided by siunitx package inside of the solution.

1 Answer 1

2

I remember an approach provided by the user gusbrs which is about using the facilities of the TikZ-package for drawing dashed-dotted underlines by means of the internal macros of the soul-package.

The user gusbrs published this approach as an answer to the question "Underlining words with dash-dotted line without affecting the other text in LaTeX".

Extempore I can only offer deriving a quick'n-dirty-workaround from this approach in terms of an environment FillInTheBlanksText.

That environment can be used for creating fill-in-the-blanks-texts. That environment takes an optional argument where you can specify the look of the fill-in-the-blanks-text via a comma-separated keyval-list.

More details are in the section "Documentation" of the example below.

Please don't overlook the "Watch out"-hints!

Be aware that I just wrote this piece of work impromptu.

Therefore: !!! No warranties - use at your own risk !!!

%% FillInTheBlanks.tex
%%
%% Copyright by Ulrich Diez ([email protected])
%% Date: April 08, 2020
%% License: LPPL
%% Format: LaTeX 2e
%% Documentclass: article
%% Required packages: soul, tikz, inputenc
%%
%% !!! No warranties - use at your own risk !!!
%%
\makeatletter
%------------------------------------------------------------------------------
% Code that could be moved to a newly to create LaTeX2e-package but currently
% is nested into a \makeatletter..\makeatother-pair---documentation/user-manual
% is below the code, in the section"Documentation":
%------------------------------------------------------------------------------
\RequirePackage{soul, tikz}%
\usetikzlibrary{calc}%
%------------------------------------------------------------------------------
% Define pgfkeys for 
% - the style of the underlining
% - the color of the underlining
% - the color of the (underlined) text
% - the font used for (underlined) text
% - writing text only
% - drawing lines only
% - writing text and drawing lines
\pgfkeys{%
  /BlankToFill/Aboveskip/.initial=\parskip,
  /BlankToFill/Belowskip/.initial=\parskip,
  /BlankToFill/Linestyle/.initial=solid,
  /BlankToFill/Linecolor/.initial=black,
  /BlankToFill/Textcolor/.initial=blue,
  /BlankToFill/Textfontcommand/.initial=\fontsize{17}{23}\itshape,
  /BlankToFill/Whitespaceonly/.code=\underlinefalse\visiblelettersfalse,
  /BlankToFill/Whitespaceonly/.value forbidden,
  /BlankToFill/Textonly/.code=\underlinefalse\visibleletterstrue,
  /BlankToFill/Textonly/.value forbidden,
  /BlankToFill/Underlinesonly/.code=\underlinetrue\visiblelettersfalse,
  /BlankToFill/Underlinesonly/.value forbidden,
  /BlankToFill/Underlinedtext/.code=\underlinetrue\visibleletterstrue,
  /BlankToFill/Underlinedtext/.value forbidden,
  /BlankToFill/UnderlinedtextDefault/.style={/BlankToFill/Underlinedtext},
  /BlankToFillDefaults/Aboveskip/.code=\pgfkeys{%
    /BlankToFill/Aboveskip/.initial=#1,
  },
  /BlankToFillDefaults/Aboveskip/.value required,
  /BlankToFillDefaults/Belowskip/.code=\pgfkeys{%
    /BlankToFill/Belowskip/.initial=#1,
  },
  /BlankToFillDefaults/Belowskip/.value required,
  /BlankToFillDefaults/Linestyle/.code=\pgfkeys{%
    /BlankToFill/Linestyle/.initial=#1,
  },
  /BlankToFillDefaults/Linestyle/.value required,
  /BlankToFillDefaults/Linecolor/.code=\pgfkeys{%
    /BlankToFill/Linecolor/.initial=#1,
  },
  /BlankToFillDefaults/Linecolor/.value required,
  /BlankToFillDefaults/Textcolor/.code=\pgfkeys{%
    /BlankToFill/Textcolor/.initial=#1,
  },
  /BlankToFillDefaults/Textcolor/.value required,
  /BlankToFillDefaults/Textfontcommand/.code=\pgfkeys{%
    /BlankToFill/Textfontcommand/.initial=#1,%
  },
  /BlankToFillDefaults/Textfontcommand/.value required,
  /BlankToFillDefaults/Whitespaceonly/.code=\pgfkeys{%
    /BlankToFill/UnderlinedtextDefault/.style={/BlankToFill/Whitespaceonly},
  },
  /BlankToFillDefaults/Whitespaceonly/.value forbidden,
  /BlankToFillDefaults/Textonly/.code=\pgfkeys{%
    /BlankToFill/UnderlinedtextDefault/.style={/BlankToFill/Textonly},
  },
  /BlankToFillDefaults/Textonly/.value forbidden,
  /BlankToFillDefaults/Underlinesonly/.code=\pgfkeys{%
    /BlankToFill/UnderlinedtextDefault/.style={/BlankToFill/Underlinesonly},
  },
  /BlankToFillDefaults/Underlinesonly/.value forbidden,
  /BlankToFillDefaults/Underlinedtext/.code=\pgfkeys{%
    /BlankToFill/UnderlinedtextDefault/.style={/BlankToFill/Underlinedtext},
  },
  /BlankToFillDefaults/Underlinedtext/.value forbidden,
}%
\newcommand\SetFillInTheBlanksTextDefaults[1]{%
  \pgfkeys{/BlankToFillDefaults/.cd,#1,}%
}%
%------------------------------------------------------------------------------
% A command for drawing dashed lines from within soul-package via tikz-package:
%  The command \dotuline is derived/copied from the command \dashdotuline 
%  which was written and published by the user "gusbrs" 
%    (URL: <https://tex.stackexchange.com/users/105447/gusbrs>)
%  in her/his answer to the question "Underlining words with dash-dotted line
%  without affecting the other text in LaTeX 
%    (URL: <https://tex.stackexchange.com/a/376364/118714>).
%------------------------------------------------------------------------------
\newlength\LineWidth
\setlength\LineWidth{0.7pt}%
\newlength\baseliney
\setlength\baseliney{-1.5pt}%
\newcommand\highlight@DoHighlight{%
    \expandafter\expandafter\expandafter\draw
    \expandafter\expandafter\expandafter[%
      \pgfkeysvalueof{/BlankToFill/Linestyle}, HLcolor,line width=\LineWidth,opacity=.5%
    ]%
    ($(begin highlight)+(0,\baseliney)$) -- ($(end highlight)+(0,\baseliney)$) ;
}%
\newcommand{\highlight@BeginHighlight}{%
    \coordinate (begin highlight) at (0,0) ;
}%
\newcommand{\highlight@EndHighlight}{%
    \coordinate (end highlight) at (0,0) ;
}%
\newdimen\highlight@previous
\newdimen\highlight@current
\DeclareRobustCommand*\dashdotuline[1][]{%
    \tikzset{this highlighter/.style={#1}}%
    \SOUL@setup
    %
    \def\SOUL@preamble{%
        \begin{tikzpicture}[overlay, remember picture]%
        \highlight@BeginHighlight
        \highlight@EndHighlight
        \end{tikzpicture}%
    }%
    %
    \def\SOUL@postamble{%
        \begin{tikzpicture}[overlay, remember picture]%
        \highlight@EndHighlight
        \highlight@DoHighlight
        \end{tikzpicture}%
    }%
    %
    \def\SOUL@everyhyphen{%
        \discretionary{%
            \SOUL@setkern\SOUL@hyphkern
            \ifvisibleletters\SOUL@sethyphenchar\else\phantom{\SOUL@sethyphenchar}\fi
            \tikz[overlay, remember picture] \highlight@EndHighlight ;%
        }{}{\SOUL@setkern\SOUL@charkern}%
    }%
    %
    \def\SOUL@everyexhyphen##1{%
        \SOUL@setkern\SOUL@hyphkern
        \ifvisibleletters\hbox{##1}\else\phantom{\hbox{##1}}\fi
        \discretionary{%
            \tikz[overlay, remember picture] \highlight@EndHighlight ;%
        }{}{\SOUL@setkern\SOUL@charkern}%
    }%
    %
    \def\SOUL@everysyllable{%
        \begin{tikzpicture}[overlay, remember picture]
        \path let \p0 = (begin highlight), \p1 = (0,0) in \pgfextra
        \global\highlight@previous=\y0
        \global\highlight@current =\y1
        \endpgfextra (0,0) ;
        \ifdim\highlight@current < \highlight@previous
        \highlight@DoHighlight
        \highlight@BeginHighlight
        \fi
        \end{tikzpicture}%
        \ifvisibleletters\the\SOUL@syllable\else\phantom{\the\SOUL@syllable}\fi
        \tikz[overlay, remember picture] \highlight@EndHighlight ;%
    }%
    %
    \ifvisibleletters\else
      \def\SOUL@underline##1{{%
        \setbox\z@\hbox{\phantom{##1}}%
        \dimen@=\wd\z@
        \dimen@i=\SOUL@uloverlap
        \advance\dimen@2\dimen@i
        \rlap{%
          \null
          \kern-\dimen@i
          \SOUL@ulcolor{\SOUL@ulleaders\hskip\dimen@}%
        }%
        \unhcopy\z@
      }}%
    \fi
    \SOUL@
}%
%------------------------------------------------------------------------------
\newif\ifunderline\underlinefalse
\newif\ifvisibleletters\visibleletterstrue
\newcommand\UD@PassFirstToSecond[2]{#2{#1}}%
\newenvironment{FillInTheBlanksText}[1][]{%
  \newcommand\BlankToFill[1]{%
    \begingroup
    \ifunderline
      \expandafter\expandafter\expandafter\UD@PassFirstToSecond
      \expandafter\expandafter\expandafter{%
        \pgfkeysvalueof{/BlankToFill/Linecolor}%
      }{\colorlet{HLcolor}}%
    \else
      \colorlet{HLcolor}{white}%
    \fi
    \ifvisibleletters
      \expandafter\expandafter\expandafter\color
      \expandafter\expandafter\expandafter{%
        \pgfkeysvalueof{/BlankToFill/Textcolor}%
      }%
    \fi
    \pgfkeysvalueof{/BlankToFill/Textfontcommand}%
    \selectfont
    \dashdotuline{##1}%
    \endgroup
  }%
  \par
  \pgfkeys{/BlankToFill/.cd,UnderlinedtextDefault,#1}%
  {%
    \pgfkeysvalueof{/BlankToFill/Textfontcommand}%
    \selectfont
    \vspace{-\parskip}%
    \vspace{-\dp\strutbox}%
    \vspace{-\lineskip}%
    \vspace{\pgfkeysvalueof{/BlankToFill/Aboveskip}}%
    \edef\@tempa{%
      \baselineskip=\the\baselineskip
      \def\noexpand\baselinestretch{\baselinestretch}%
    }%
  \expandafter}\@tempa\selectfont
  \ignorespaces
}{%
  \par\vspace{-\parskip}%
  {%
    \pgfkeysvalueof{/BlankToFill/Textfontcommand}%
    \selectfont
    \vspace{\pgfkeysvalueof{/BlankToFill/Belowskip}}%
  }%
}%
%------------------------------------------------------------------------------
% Documentation:
%
% There is an environment whose name is FillInTheBlanksText .
%
% That environment is intended to provide a scope where you can
% write a fill-in-the-blanks-text.
%
% That environment takes an optional argument where you can
% specify the look of the fill-in-the-blanks-text via a
% comma-separated keyval-list:
%
% ---------------+-------------------------+-----------------------------------
% Key:           |Default-Value:           |Purpose:  
% ----           |--------------           |--------
% ---------------+-------------------------+-----------------------------------
% Linestyle      |solid                    |The style of the underlines.
%                |                         |Possible values:
%                |                         |solid, dotted, densely dotted,
%                |                         |loosely dotted, dashed,
%                |                         |densely dashed, loosely dashed,
%                |                         |dash dot, densely dash dot,
%                |                         |loosely dash dot, dash dot dot,
%                |                         |densely dash dot dot,
%                |                         |loosely dash dot dot
% ---------------+-------------------------+-----------------------------------
% Linecolor      |black                    |The color of the underlines.
%                |                         |Possible values:
%                |                         |All definded colors.(See manual of
%                |                         |tikz-package/xxcolor)
% ---------------+-------------------------+-----------------------------------
% Textfontcommand|\fontsize{17}{23}\itshape|The font for the fill-in-the-
%                |                         |blanks-texts.
% ---------------+-------------------------+-----------------------------------
% Textcolor      |blue                     |The color of the fill-in-the-
%                |                         |blanks-texts.
%                |                         |Possible values:
%                |                         |All definded colors.(See manual of
%                |                         |tikz-package/xxcolor)
% ---------------+-------------------------+-----------------------------------
% Aboveskip      |\parskip                 |The vertical distance between the
%                |                         |bottomline (not baseline) of the 
%                |                         |box which forms the last line of 
%                |                         |text above the environment and the
%                |                         |topline (not baseline) of the
%                |                         |first line of the environment.
%                |                         |Possible values:
%                |                         |A length. If you use \baselineskip
%                |                         |or \parskip or the like, things 
%                |                         |will be calculated with the font in
%                |                         |use for writing the fill-in-the-
%                |                         |blanks-text.
% ---------------+-------------------------+-----------------------------------
% Belowskip      |\parskip                 |The vertical distance between the
%                |                         |bottomline (not baseline) of the
%                |                         |last line of the environment and
%                |                         |the topline (not baseline) of the 
%                |                         |box which forms the first line of 
%                |                         |text below the environment.
%                |                         |Possible values:
%                |                         |A length. If you use \baselineskip
%                |                         |or \parskip or the like, things 
%                |                         |will be calculated with the font in
%                |                         |use for writing the fill-in-the-
%                |                         |blanks-text.
% ---------------+-------------------------+-----------------------------------
% Textonly       |[none]                   |Print only the texts.
%                |                         |Possible values: None.
% ---------------+-------------------------+-----------------------------------
% Underlinesonly |[none]                   |Print only the underlines.
%                |                         |Possible values: None.
% ---------------+-------------------------+-----------------------------------
% Underlinedtext |[none]                   |Print both texts and underlines.
%                |                         |Possible values: None.
% ---------------+-------------------------+-----------------------------------
% Whitespaceonly |[none]                   |Prints neither texts nor underli-
%                |                         |nes. You just get white gaps.
%                |                         |Possible values: None.
% ---------------+-------------------------+-----------------------------------
% 
% Within that environment a command \BlankToFill is defined.
%
% That command takes a mandatory argument denoting a phrase of text.
%
% \BlankToFill will process that phrase of text according to the settings
% provisionable in the optional argument of the FillInTheBlanksText-
% environment.
%
% Within the environment all lines of text will have a distance according to
% the Textfontcommand/\fontsize-command specified.
%
% There is also the command 
%
%     \SetFillInTheBlanksTextDefaults{<key-value-list>}
%
% It serves the purpose of specifying global defaults for the
% FillInTheBlanksText-environment so that you only need to specify an
% optional argument for the FillInTheBlanksText-environment when deviating
% from the defaults.
%
% This way you can, e.g., toggle the defaults in the preamble of your
% document for specifying whether to create a document with underlines
% only or with text also.
%
% The command \begin{FillInTheBlanksText} ends the paragraph LaTeX is about to
% produce when encountering that command.
%
% The command \end{FillInTheBlanksText} ends the paragraph LaTeX is about to
% produce when encountering that command.
% 
% !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
% Watch out 1:
% ============
%
% As things provided by the TikZ-package are used for drawing the underlines,
% you need to compile the document at least twice (without deleting auxiliary-
% files between compilations!) until everything matches out. After each
% compilation the .log-file will contain a hint in case another compilation is
% needed.
%
% Watch out 2:
% ============
%
% As the text of the blanks to fill in is produced by means of mechanisms of
% the soul package, all restrictions that apply to text that is to be processed
% by macros of the soul-package apply to the argument of \BlankToFill also.
%
% Watch out 3:
% ============
%
% Be aware that I just wrote this piece of work impromptu.
%
% Therefore: !!! No warranties - use at your own risk !!!
% !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
%------------------------------------------------------------------------------
% End of code that could be moved to a newly to create LaTeX2e-package
\makeatother
%
% Code exhibiting the usage:
%
\documentclass[a4paper]{article}
\usepackage[latin1]{inputenc}

\hyphenation{ph-r-a-se}
\setlength{\parindent}{0pt}
\parskip=\baselineskip

\SetFillInTheBlanksTextDefaults{%
  Linestyle=densely dotted,
  Linecolor=black,
  Textcolor=blue,
  Textfontcommand=\fontsize{17}{23}\itshape,
  Underlinedtext,
  Aboveskip=\dimexpr\baselineskip-\dp\strutbox,
  Belowskip=\dimexpr\baselineskip-\dp\strutbox,
}

\begin{document}

%----------- Key Underlinesonly ---------------------------------------

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

Key in use with environment \verb|FillInTheBlanksText|:
\verb|Underlinesonly|

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
\begin{FillInTheBlanksText}[Underlinesonly]
Text. \BlankToFill{%
  This phrase is part of the blank to fill---%
  abcdefghijklmnopqrstuvwxyzäöüß.%
}
This phrase is not part of a blank to fill.
This phrase is not part of a blank to fill.
\BlankToFill{%
  This phrase is part of the blank to fill---%
  abcdefghijklmnopqrstuvwxyzäöüß.%
}
This phrase is not part of a blank to fill.
This phrase is not part of a blank to fill.
\BlankToFill{%
  This phrase is part of the blank to fill---%
  abcdefghijklmnopqrstuvwxyzäöüß.%
}
Text.
\end{FillInTheBlanksText}
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

\textbf{Provide a pattern for all primitive pythagorean triples
\(x^2+y^2=z^2\), \(2\mid x\), \(x>0\), \(y>0\), \(z>0\):}
\begin{FillInTheBlanksText}[Textfontcommand=\fontsize{17}{23}, Underlinesonly]
\BlankToFill{%
  \mbox{\makebox[\textwidth][l]{\hfill $x=2st$,\hfill}}\\
  \mbox{\makebox[\textwidth][l]{\hfill $y=s^2-t^2$,\hfill}}\\
  \mbox{\makebox[\textwidth][l]{\hfill $z=s^2+t^2$,\hfill}}\\
  \mbox{\makebox[\textwidth][l]{%
   \hfill $s>t>0, \textrm{gcd}(s,t)=1, s\not\equiv t (\textrm{mod }2)$\hfill
  }}%
}%
\end{FillInTheBlanksText}

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

\newpage %----------- Key Underlinedtext (default)-------------------------------

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

Key in use with environment \verb|FillInTheBlanksText|:
\verb|Underlinedtext|

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
\begin{FillInTheBlanksText}
Text. \BlankToFill{%
  This phrase is part of the blank to fill---%
  abcdefghijklmnopqrstuvwxyzäöüß.%
}
This phrase is not part of a blank to fill.
This phrase is not part of a blank to fill.
\BlankToFill{%
  This phrase is part of the blank to fill---%
  abcdefghijklmnopqrstuvwxyzäöüß.%
}
This phrase is not part of a blank to fill.
This phrase is not part of a blank to fill.
\BlankToFill{%
  This phrase is part of the blank to fill---%
  abcdefghijklmnopqrstuvwxyzäöüß.%
}
Text.
\end{FillInTheBlanksText}
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

\textbf{Provide a pattern for all primitive pythagorean triples
\(x^2+y^2=z^2\), \(2\mid x\), \(x>0\), \(y>0\), \(z>0\):}
\begin{FillInTheBlanksText}[Textfontcommand=\fontsize{17}{23}]
\BlankToFill{%
  \mbox{\makebox[\textwidth][l]{\hfill $x=2st$,\hfill}}\\
  \mbox{\makebox[\textwidth][l]{\hfill $y=s^2-t^2$,\hfill}}\\
  \mbox{\makebox[\textwidth][l]{\hfill $z=s^2+t^2$,\hfill}}\\
  \mbox{\makebox[\textwidth][l]{%
   \hfill $s>t>0, \textrm{gcd}(s,t)=1, s\not\equiv t (\textrm{mod }2)$\hfill
  }}%
}%
\end{FillInTheBlanksText}

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

\newpage %----------- Key Textonly ---------------------------------------

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

Key in use with environment \verb|FillInTheBlanksText|:
\verb|Textonly|

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
\begin{FillInTheBlanksText}[Textonly]
Text. \BlankToFill{%
  This phrase is part of the blank to fill---%
  abcdefghijklmnopqrstuvwxyzäöüß.%
}
This phrase is not part of a blank to fill.
This phrase is not part of a blank to fill.
\BlankToFill{%
  This phrase is part of the blank to fill---%
  abcdefghijklmnopqrstuvwxyzäöüß.%
}
This phrase is not part of a blank to fill.
This phrase is not part of a blank to fill.
\BlankToFill{%
  This phrase is part of the blank to fill---%
  abcdefghijklmnopqrstuvwxyzäöüß.%
}
Text.
\end{FillInTheBlanksText}
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

\textbf{Provide a pattern for all primitive pythagorean triples
\(x^2+y^2=z^2\), \(2\mid x\), \(x>0\), \(y>0\), \(z>0\):}
\begin{FillInTheBlanksText}[Textfontcommand=\fontsize{17}{23}, Textonly]
\BlankToFill{%
  \mbox{\makebox[\textwidth][l]{\hfill $x=2st$,\hfill}}\\
  \mbox{\makebox[\textwidth][l]{\hfill $y=s^2-t^2$,\hfill}}\\
  \mbox{\makebox[\textwidth][l]{\hfill $z=s^2+t^2$,\hfill}}\\
  \mbox{\makebox[\textwidth][l]{%
   \hfill $s>t>0, \textrm{gcd}(s,t)=1, s\not\equiv t (\textrm{mod }2)$\hfill
  }}%
}%
\end{FillInTheBlanksText}

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

\newpage %----------- Key Whitespaceonly ---------------------------------

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

Key in use with environment \verb|FillInTheBlanksText|:
\verb|Whitespaceonly|

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
\begin{FillInTheBlanksText}[Whitespaceonly]
Text. \BlankToFill{%
  This phrase is part of the blank to fill---%
  abcdefghijklmnopqrstuvwxyzäöüß.%
}
This phrase is not part of a blank to fill.
This phrase is not part of a blank to fill.
\BlankToFill{%
  This phrase is part of the blank to fill---%
  abcdefghijklmnopqrstuvwxyzäöüß.%
}
This phrase is not part of a blank to fill.
This phrase is not part of a blank to fill.
\BlankToFill{%
  This phrase is part of the blank to fill---%
  abcdefghijklmnopqrstuvwxyzäöüß.%
}
Text.
\end{FillInTheBlanksText}
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.
This is not part of a FillInTheBlanksText-environment.

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

\textbf{Provide a pattern for all primitive pythagorean triples
\(x^2+y^2=z^2\), \(2\mid x\), \(x>0\), \(y>0\), \(z>0\):}
\begin{FillInTheBlanksText}[Textfontcommand=\fontsize{17}{23}, Whitespaceonly]
\BlankToFill{%
  \mbox{\makebox[\textwidth][l]{\hfill $x=2st$,\hfill}}\\
  \mbox{\makebox[\textwidth][l]{\hfill $y=s^2-t^2$,\hfill}}\\
  \mbox{\makebox[\textwidth][l]{\hfill $z=s^2+t^2$,\hfill}}\\
  \mbox{\makebox[\textwidth][l]{%
   \hfill $s>t>0, \textrm{gcd}(s,t)=1, s\not\equiv t (\textrm{mod }2)$\hfill
  }}%
}%
\end{FillInTheBlanksText}

\vspace{-\ht\strutbox}
\noindent\null\cleaders\hrule height 1.2pt\hfill\null
\vspace{-\dp\strutbox}

\end{document}

In the .pdf-file that results from compiling the example, you can check the position of elements as follows:

  • Zoom the height of the page to fit the height of the window where the .pdf-file is displayed.
  • Set the viewing-mode to "single page" and "non-continuous".
  • Now you can play "virtual flipbook" by scrolling between pages:
    Some elements should vanish/pop up, but none of the elements should be shifted vertically/horizontally.

enter image description here

enter image description here

enter image description here

enter image description here

8
  • What a detailled and complete answer ! It is, for now, far away than what i'm able to code. I'm testing the code in different documents to see limitations. Here are some questions : 1) [s]ulem vs soul[/s] -> solution found [url=tex.stackexchange.com/questions/74893/…. 2) Is the particular structure with \mbox{\makebox[]{}} derived from soul limitations ? Insert it in the definition command can't be a trick to avoid to write them for math expressions ? 3) Are there risks to use soulutf8 instead of soul ? I'm still testing
    – Piroooh
    Apr 8, 2020 at 9:28
  • 4) Is there a way to make the line spawning to the end of the remaining space ? I'm trying with \mbox \hfill and \hspace but with no results.. 5) I succeeded with siunitx command. Maybe we should create a chat room if you agree.
    – Piroooh
    Apr 8, 2020 at 9:56
  • Ad 1) What is the question? ;-) Ad 2) "derived from soul limitations: Yes. If I got the documentation of soul right, \mbox is carried out immediately. \makebox is used in order to get a box of specified width which will be underlined, even in these places where the content of that box consists of whitespace-glue. " can't be a trick..for math expressions": \mbox/\makebox is not used because of math occurring in the text. It is used for specifying the width of the box in a way where the box is underlined on the while width even if the box ends with a lot of whitespace-glue. ... Apr 9, 2020 at 12:19
  • ... The crucial thing is: If you don't use \makebox but do something like \hbox to\textwidth{\hfill text\hfill\null}, the underlining will not span the whole textwidth but underlining will end with the last "t" of the phrase "text". Ad 3) I don't know. I don't think so. soulutf8 is sort of a wrapper which converts the input in utf8-encoding to some 8-bit encoding which forms a subset of utf-8 which is sufficient for typesetting the listing. Perhaps, if inputenc is loaded, and if no utf8-specific characters are used in the listing, it is sufficient to use inputenc's commands for ... Apr 9, 2020 at 12:36
  • ...switching the inpute-ncoding before and after the listing/the fill-in-the-blanks-text. Ad 4) As I did with the math-thingies, you can use \mbox{\makebox...} for creating boxes of specified width. I used this for specifying for each line of text a box of width \textwidth. You can do the same. Or you can, outside the environment, switch to the font in use inside the environment and do calculations of widths of single boxes and then, inside the environment, put the pieces together by lining up \mbox{\makebox...`-boxes of calculated widths. Apr 9, 2020 at 12:36

You must log in to answer this question.

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