1

Consecutively to this question, I need to add something after the inclusion of on itemed file to be sure that what comes next begins on a nexwline. I don't want skip blanck line in the source I'd like the command makes it for me.

A MWE :

enter image description here

A more realistic example, problem between n10 et n11 :

enter image description here

\begin{filecontents*}{typea.tex}
here latex stuff
\end{filecontents*}

\begin{filecontents*}{typeb.tex}
\begin{minipage}{5cm}
\item here latex stuff

more stuff
\end{minipage}
\end{filecontents*}

\documentclass{article}
\usepackage{xparse,l3regex}

% #### tarassinput pour les item dans les minipages
\ExplSyntaxOn
\NewDocumentCommand{\tarassinput}{om}
 {
  \tl_set_from_file:Nnn \l_tarass_input_tl { } { #2 }
  % \A matches the start
  % \c{begin} matches \begin
  % \cB. matches any "group begin" token
  % \cE. matches any "group end" token
  \regex_match:nVF
    { \A \c{begin} \cB. minipage \cE. }  
    \l_tarass_input_tl 
    { \IfValueTF{#1}{ \item[#1] }{ \item } }
  \tl_use:N \l_tarass_input_tl  
 }
\cs_generate_variant:Nn \regex_match:nnF { nV } 
\ExplSyntaxOff

\begin{document}

\begin{itemize}
\item Start
\tarassinput{typea}
\tarassinput{typeb}
\end{itemize}

\end{document}
Tarass
  • 16,912
  • Your problem has nothing to do with latex 3. You have in the middle of the list a minipage with an item. minipage changes quite a number of parameter -- starting from parskip -- and lists behaves differently inside a minipage then outside. It would need quite some time to figure out how to correct all the side effect. Why don't you remove the minipages? – Ulrike Fischer Apr 15 '16 at 09:26
  • It is a mwe example, so minipage seems useless but they have their purpose. And it is a latex 3 problem because I try to understand the syntax for the alternatives on the test to add something for each case. Egreg gave a link http://tex.stackexchange.com/questions/34971/how-to-keep-a-constant-baselineskip-when-using-minipages-or-parboxes but I cant use it because of the l3 syntax problem. – Tarass Apr 15 '16 at 09:31
  • The edit shows that you're on the wrong track. Sorry, I can't help. – egreg Apr 15 '16 at 10:25

2 Answers2

3

Your minipages should be like

\begin{minipage}[b]{\linewidth}
Material\par\xdef\tpd{\theprevdepth}
\end{minipage}

Then the regex match code could be

\NewDocumentCommand{\tarassinput}{om}
 {
  \tl_set_from_file:Nnn \l_tarass_input_tl { } { #2 }
  \regex_match:nVTF { \A \c{begin} \cB. minipage \cE. } \l_tarass_input_tl
   {% true branch: input the minipage and restore \prevdepth
    \tl_use:N \l_tarass_input_tl \par\prevdepth=\tpd\scan_stop:
   }
   {% false branch
    \IfValueTF{#1}{ \item[#1] }{ \item }
    \tl_use:N \l_tarass_input_tl
   }
 }
\cs_generate_variant:Nn \regex_match:nnTF { nV }
egreg
  • 1,121,712
  • 1
    Can't we do \AtEndEnvironment{minipage}{\par\xdef\tpd{\theprevdepth}}? – Manuel Apr 15 '16 at 10:05
  • @egreg Sorry for bothering you but my problem was not exactly I thought, see my edit. – Tarass Apr 15 '16 at 10:17
  • @egreg If I add a black line to make a new line after \tl_use:N \l_tarass_input_tl there is no difference. Why ? – Tarass Apr 15 '16 at 10:26
  • @Tarass It's impossible to answer a question where you give no clue about the real problem. The image you show in the edit has nothing to do with the stated problem. – egreg Apr 15 '16 at 10:32
  • @egreg If one jump a line between the two tarassinput the problem is solved. I there a way yo do that automatically ? – Tarass Apr 15 '16 at 10:37
  • @Tarass If your minipage based files just contain some graphics, the simplest thing is to add \medskip before and after \tl_use:N \l_tarass_input_tl in the “true branch” above; no need to take care of baselines. – egreg Apr 15 '16 at 10:42
  • @egreg \medskip is too much, \smallskip is enough just before, I add a \par after in the both branches. I'm very sorry for the loss of your time. – Tarass Apr 15 '16 at 10:56
2

Too long for a comment: The problem is not related to latex 3 or the input method. It can be shown with a MWE like the following. As one can see the minipage disturbs the spacing. And while one can find with careful analyzing of the code suitable values to correct the spacing, I would avoid such a structure at all costs. It looks unnatural and wrong.

\documentclass{article}

\begin{document}

\begin{itemize}

\item Start

\item
here latex stuff

\begin{minipage}[t]{5cm}
\item here latex stuff

more stuff

\item more stuff
\end{minipage}

\item outside minipage

\item outside minipage
\end{itemize}

\end{document}

enter image description here

Imho you are on the wrong track. Why do you put the \item inside the minipage? When it is outside everything is fine:

\documentclass{article}
\usepackage{lipsum}
\begin{document}

\begin{itemize}

\item Start

\item
here latex stuff


\item \begin{minipage}[t]{5cm}
\lipsum*[1]
more stuff\strut
\end{minipage}\quad
\begin{minipage}[t]{3cm}\vspace{0pt}\rule{1cm}{3cm}
\end{minipage}

\item more stuff


\item outside minipage

\item outside minipage
\end{itemize}

\end{document}

You could also use the addmargin environment (from the KOMA-classes) to make the text smaller.

enter image description here

Ulrike Fischer
  • 327,261
  • Thank you for your concern, but I need this minipages because I have text and picture side by side: the text in the minipage on the left and the tikzpicture on the right with a \hfill between. I have to make a list of such things and I'll post you an example in a moment. – Tarass Apr 15 '16 at 09:54
  • See my edit, it is a small side problem in fact. But I can find solved it in this case. – Tarass Apr 15 '16 at 10:18