0

I'm writing something code-like, and I'm indenting things to align vertically with paired arguments. My solution to align the text is to use nested arrays, but it might make sense to change to tabulars, as I might want to leave mathmode. My tables look something like this:

\begin{array}[t]{ll}
  functionName:
    & param1 \\
    & param2
\end{array}

Because it is very common to replace param1 and param2 with more function calls, and because this is a lot to type each time, I've converted this into a macro:

\newcommand{\nest}[3]{
  \begin{array}[t]{@{}l@{}l@{}}
    #1
    &#2\\
    &#3
  \end{array}
}

The @{} is because I want to have no extra space between cells; I'd like it to appear as though each individual line is a single string of text that is indented only at the beginning.

I would like a way to add a vertical line down from the bottom-left corner of functionName to the bottom of the array. I can get close to what I want by replacing {ll} with {|ll}, but that adds the border along the entire left edge, rather than skipping the first line of text.

A previous suggestion was to use \multicolumn to remove the border from the left edge only for the first row. If param1 is replaced with a function call, the first table row becomes taller, but the amount of border I want to remove stays the same. Another suggestion was to determine how many columns I'll end up with, and use \multicolumn to have things take up the correct width. I think this suggestion was because my previous MWE was too minimal, so I've made a new example.

Here's the new example code, which includes the method of removing the border from the first row:

\documentclass{article}

\newcommand{\nest}[3]{
  \begin{array}[t]{|@{}l@{}l@{}}
    \multicolumn{1}{@{}l@{}}{#1}
    &#2\\
    &#3
  \end{array}
}

\newcommand{\AND}[2]{\nest{\wedge}{#1}{#2}}
\newcommand{\IMPLY}[2]{\nest{\rightarrow}{#1}{#2}}
\newcommand{\XNOR}[2]{\nest{\leftrightarrow}{#1}{#2}}

\begin{document}

\[\XNOR{\IMPLY{\AND{\IMPLY{P}{Q}}{P}}{Q}}
       {\IMPLY{\AND{\neg Q}{\IMPLY{P}{Q}}}{\neg P}}\]

\end{document}

This produces:

borders removed from first rows

I would like something like this:

borders removed just from first line of first rows

Is there a nice way to do this?

11
  • Please add a sketch of the desired output.
    – leandriis
    Apr 16, 2020 at 6:05
  • An example including the nesting tables might also be helpful. In the mean time I guess you might be interested in using multicolumn to remove the vertical line from the first table row.
    – leandriis
    Apr 16, 2020 at 6:30
  • 2
    \documentclass{article} \begin{document} \begin{array}[t]{|ll} \multicolumn{1}{l}{functionName:} & param1 \\ & param2 \\ & param3 \end{array} \end{document}?
    – leandriis
    Apr 16, 2020 at 6:40
  • Edited to include a nested table, a screenshot of the output with {@{}|ll}, and an edit from Paint to show what I want the output to be.
    – Pi Fisher
    Apr 16, 2020 at 7:58
  • Because of the nesting, removing the vertical line from the first table row is often removing too much: in the example I just added, the first table row is two rows of text, and I only want to remove the vertical line from one row of text.
    – Pi Fisher
    Apr 16, 2020 at 8:01

0

You must log in to answer this question.

Browse other questions tagged .