Text FormattingMaking Sense of Code

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Making Sense of Code

Post by cgnieder »

LaTexLearner wrote:What I meant about 3cm of space was 3cm of vertical space. Maybe this would have two horizontal rules all the way across or maybe not. Is that possible?
My suggestion would be to use \answerline macro only for usage in the current text flow. For bigger chunks that need some vertical space I'd suggest defining an environment. I'll post something later.
LaTexLearner wrote:Also, what is the "adapted proposal" you mentioned?
I meant this http://latex-community.org/forum/viewto ... 494#p91512 but it sounds like I misunderstood your question.
site moderator & package author

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Making Sense of Code

Post by Johannes_B »

Currently, the macro for an answer is meant for single words, not for paragraphs of text. I am not quite sure what you are trying to achieve? Maybe have a look at package exsheets, it is customizable and great for doing exam sheets and similar stuff.

Code: Select all

\documentclass{article}
\begin{document}
Is there a question?\phantom{42}Really?

Is there a question?42Really?

\rule{0pt}{3cm}

Hello? Anybody here?

\vspace{4cm}

Anybody? Where is everyone?
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Making Sense of Code

Post by cgnieder »

Johannes_B wrote:I am not quite sure what you are trying to achieve?
This will become clear with a little history :)

LaTeXLearner asked a question over at TeX.se (actually using the exsheets package) and I gave an answer. In the comments he asked whether we could discuss the code so I suggested to do that here since a forum is much better suited for discussions.

Best
site moderator & package author
LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

Making Sense of Code

Post by LaTexLearner »

cgnieder wrote:
LaTexLearner wrote:What I meant about 3cm of space was 3cm of vertical space. Maybe this would have two horizontal rules all the way across or maybe not. Is that possible?
My suggestion would be to use \answerline macro only for usage in the current text flow. For bigger chunks that need some vertical space I'd suggest defining an environment. I'll post something later.
I think that I understand the majority of this thread well enough, with the exception of all the @ use which sounds pretty complicated.

I've started a new thread for longer answers. (I posted it on here; not sure if it should have gone on tex.stackexchange instead... this forum seems easier to use, though. :) )
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Making Sense of Code

Post by Stefan Kottwitz »

Hi,
LaTexLearner wrote:not sure if it should have gone on tex.stackexchange instead... this forum seems easier to use, though. :) )
I'm on tex.stackexchange too. But since a while I rarely post there. I like talking here in the LaTeX Community forum, it feels more free to me and I feel relaxed here, not so on stackexchange with strict rules, often closing questions and such.

Stefan
LaTeX.org admin
LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

Making Sense of Code

Post by LaTexLearner »

cgnieder wrote:
LaTexLearner wrote:Also, is there any way to set the answer space so that the default length is, say, 2cm, but there is an optional argument to make it longer?
One possibility: change the definition of \answerline like this:

Code: Select all

\newcommand\answerline[2][\answerspace]{%
  \begingroup
    \ifdim#1=\answerspace
    \else
      \setlength\answerspace{#1}%
    \fi
    \ifmmode
      \answerline@math{#2}%
    \else
      \answerline@text{#2}%
    \fi
  \endgroup
}
I'm trying to adjust this code so that if there is a sequence of fill-in-the-blank exercises, the first one is an example, i.e. already filled in regardless of the setting of \SetupExSheets{...}.

I tried the code below, but it did not seem to work. I also imagine there is a more elegant way to begin the code instead of using #1 twice in the first line.

The goal was to have it make this macro \exampleline[optional length]{filled in text}

Code: Select all

\newcommand\example[1]{\PrintSolutionsTF{#1}{#1}}

\newcommand\exampleline[2][\answerspace]{  % \answerspace is defined above  
  \begingroup
    \ifdim#1=\answerspace
    \else
      \setlength\answerspace{#1}%
    \fi
    \ifmmode
      \answerline@math{#2}%
    \else
      \answerline@text{#2}%
    \fi
  \endgroup
}
Post Reply